With just a subset of XPath, powerful XSLT stylesheets can be created to process very complex XML instances.
Before digging into Schematron, I'll demonstrate how XSLT can easily be used to validate XML instances. You can imagine other combinations of templates that validate more complex XML structures. It takes a Schematron schema definition (in XML) that describes the constraints.
Pattern elements allow the user to group schema constraints logically.
Some examples of logical groupings are: Text Only Elements, Valid Root Element, Check for ID Attribute. They may also have a attribute that refers to a URL for user documentation of the schema.
The Validation Type property of the Xml Reader Settings object is set to to enforce validation of the XML document by the Create method of the Xml Reader object.
A Validation Event Handler is added to the Xml Reader Settings object to handle any Warning or Error events raised by errors found during the validation process of both the XML document and the schema.
The XML Schema language is an XML application and will likely become the standard way XML schemas are formally declared.
DTDs are written in a syntax other than XMLs' and rely upon post-processing for validation. However, DTDs are a step behind the direction XML technologies are evolving: they don't support namespaces, and they use a non-XML syntax.Once a document is identified as belonging to a class of documents, many assumptions about its structure can be made.DTDs were the first standard mechanism for XML validation, and for all practical purposes still are.XML documents can be validated against an XML schema definition language (XSD) schema in an Xml Schema Set. XML documents are validated by the Create method of the Xml Reader class. Schema namespace contains extension methods that make it easy to validate an XML tree against an XSD file when using LINQ to XML.