Schematron is a structural, rule-based validation language for XML documents. It uses XPath and XSLT to validate rules most other schemas can not.
Schematron is a rule-based validation language for XML documents. Schematron allows one to model complex relationships in XML content and to formulate rules that most other schema languages do not support. Schematron is not often used alone but is usually used along with another schema language. In this case, the other language is used to validate the grammar of the XML model and schematron is used to validate business rules.
One of its most powerful mechanisms is sch:assertion
, that allows the author of the schema to assert arbitrary XPath expressions and report any content where this assertion failed. To date, XML Schema 1.1 is the only other schema language that supports assertions (while DTD, XML Schema 1.0 and RNG do not).
Although implementations exist that work directly with schematron schemas, the canonical model is to first transform the schema into an xslt style sheet using stylesheets available at the schematron home page which can then be used to validate the input document by transforming it into Schematron Validation Report Language (SVRL), a language used for reporting the results of a schematron validation. Many of the implementations that work directly with schematron follow this canonical model internally.
An additional and highly positive feature of schematron is that the schema writer is free to write their own validation messages. This allows schematron to generate very clear explanatory error messages, a feature missing from other schema languages.
It was invented by Rick Jelliffe and is an ISO Standard. In addition to the main language, the same ISO standard defines the SVRL language used for reporting results of validations.
For a more thorough introduction to Schematron Erik Siegel's book "Schematron: A language for validating XML" might help.