Different Types of Schema Languages
While the different schema languages all operate on infoset views of documents, they have chosen different ways of defining constraints:
Constraints may be expressed as rules. In Schematron, for instance, a schema is a set of rules like “the element named
book
must have an attribute namedid
and this attribute’s content must match this specific rule....”Constraints may be expressed as a thorough description of each element and attribute like DTDs and W3C XML Schema: “it’s an element named
book
, and it has two attributes namedid
andavailable
, which look like this....”Constraints may be expressed as patterns . Patterns are used to match the structures of permissible elements, attributes, and text nodes, much as the regular expressions used in programming can be used to match characters in text. I will cover this third way of defining constraints in detail in this book because this is the method that RELAX NG uses.
The first XML schema language was the Document Type Definition (DTD), which was part of XML 1.0. DTDs provide more than just schema validation features—they include the definition of internal and external entities—but their schema features focus on describing elements. Every element and attribute used by the document type defined by the DTD must be described. Each element must have a content model, identifying which child elements or text nodes are allowed, as well as a list of permissible attributes, if any attributes are allowed. To ...
Get RELAX NG now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.