Non validating xml

Consider the following XML: If one constraint on such a document is that a short Story element may only contain an author attribute if it isn't the child of anthology element, it wouldn't be possible to represent that constraint in a DTD.These DTD handicaps aren't going unnoticed, and the W3C is presently developing an XML Schema language (currently a W3C Candidate Recommendation) that is more expressive and powerful than DTDs.

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.

This places DTDs at a disadvantage because developers must learn an additional syntax in order to define their XML schemas--but DTDs also have more severe restrictions.

DTDs are somewhat limited in their range of expression; therefore, they cannot be used to validate some XML document structures.

Schematron takes a unique approach to schemas in that it focuses on validating document instances instead of declaring a schema (as the other schema languages do).

Schematron relies almost entirely on XPath query patterns for defining these rules and checks.

Leave a Reply