Schematron is a rule-based XML validation language. It can be used for making assertions on patterns in XML nodes. For e.g. if a person (element) has "Mr" as prefix (attribute), then gender (child element) should be "male". If the assertion fails, an error message that is supplied by the author of the schema can be displayed.
Thus Schematron is capable of expressing complex constraints that cannot be expressed using XML Schema or DTD. Using XML schemas, you can only put constraints on the document structure and basic datatype validation. The following sites give good intro about this language.
http://www.schematron.com/
http://www.ldodds.com/papers/schematron_xsltuk.html
So how do we apply Schematron schema to validate XML document instances? Given below are the simple steps one should follow:
Thus Schematron is capable of expressing complex constraints that cannot be expressed using XML Schema or DTD. Using XML schemas, you can only put constraints on the document structure and basic datatype validation. The following sites give good intro about this language.
http://www.schematron.com/
http://www.ldodds.com/papers/schematron_xsltuk.html
So how do we apply Schematron schema to validate XML document instances? Given below are the simple steps one should follow:
- Create a schematron schema file
- Use a meta-stylesheet to convert this schema file into a XSLT stylesheet. ( A meta-stylesheet is a stylesheet which generates other stylesheets)
- The above generated XSLT stylesheet can be used as a XML validator against the XML instance document (using a XSLT transformation engine)
- The output of the transformation would be a XML document with validation errors.
Since the fundamental technologies used as XML Schema, XSLT and XPath; most of the XML processing APIs of Java/.NET can be used for the same.
No comments:
Post a Comment