Whether you are using XSD, DTD, or RELAX NG, there are some validations that grammar-based schema languages just can’t express or that, for practical or business reasons, you do not want to build into your basic XML models. Solution? Schematron!
Schematron is a rules-based validation/reporting language that works by making assertions about patterns found in XML documents and reporting back messages about the truth (or otherwise) of those assertions. There is no need to validate that the complete structure of a document is correct, just check one small constraint, or three. Schematron is small, powerful, and easy to learn. It can provide the best error/reporting messages in the world (you craft them for your specific situation). Even if you already use a schema language, Schematron can help for fast checking; pinpoint reporting of element and attributes presence, absence, values and value ranges, and co-constraints and other hard-to-crack edge cases.
While Schematron can work with many tree-querying languages, the class will be illustrate Schematron as it is most commonly used, with XPath, the tree-walking and expression language used with XQuery and XSLT.
Course Outline
- What is Schematron - Validations in action (short demo) - ISO and other Schematron versions - How Schematron works – Tree Processing – Introduction to XPath (context, a few axes) – Structure of a Schematron Schema (namespace, title, and pattern) - Writing a simple Schematron “schema” – Context – Assert – Report – Rules - Simple testing with Schematron – Presence of an element/attribute – Value of an attribute/element – Order of elements – How many – Co-occurrence constraints - Patterns revisited - More complex error messages
Prerequisites: Basic knowledge of XML tagging. No prior Schematron, XPath, or XSLT is required, although XPath experience would make Schematron easier.
Materials: Students may download the Oxygen trial version to their Windows or Mac laptops to follow the demonstrations on their machine. Sample materials for the demonstrations will be distributed by USB memory-stick or CD-ROM prior to the start of class.
Keywords: Schematron, validation, XPath, patterns, rules checking
Ms. Lapeyre’s main technical focus is in the markup, management, and display of large textual documents. She designs XML tag sets in DTD, XSD, and RELAX NG form, writes and teaches XSLT, and advocates using Schematron to get some kinds of validation out of the content models and into another processing layer. Loves XML pipelining, running information analysis sessions, and performing evaluations of other folks tag sets and stylesheets.
Background includes: typesetting programming and book design, database programming, proprietary generic coding languages, and pumpkin carving. Owns far too many books.