Effective XML: 50 Specific Ways to Improve Your XML
Rick Jelliffe's Schematron is a radically different approach to schema languages. Whereas other schema languages are conservative (everything not permitted is forbidden), Schematron is liberal (everything not forbidden is permitted). A Schematron schema makes assertions about the content of the document. If all assertions are true, the document is valid. Since the assertions are written in XPath, Schematron can state things that no other schema language can. Here are some examples.
Key features of Schematron include the following:
Schematron is most appropriate when:
Schematron is least appropriate when:
I don't know that I would ever pick Schematron as the sole validation layer for documents. Writing a complete Schematron schema that's equivalent to even a simple DTD is very tiresome. Used in this fashion, Schematron would be far and away the most verbose and difficult of the various schema languages. However, Schematron is not normally used in this way. Instead, it is used to attach additional constraints that are impossible to state in the other languages. It is applied as an extra validation step after a document has already been validated against a DTD or some other schema. In particular, it's often used to add co-occurrence and exclusion constraints to schemas in languages such as RELAX NG and the W3C XML Schema Language that don't have them. Some tools (e.g., the Topologi Schematron Validator) will even recognize Schematron schemas hidden inside annotations in a schema written in a different language. |