Chapter 6. RELAX NG

RELAX NG is a very powerful, yet easy to understand schema technology that can be used to validate XML instance documents. Like W3C XML Schemas, covered in the previous chapter, RELAX NG is grammar-based. It is possible for many XML instance documents to be valid according to a single RELAX NG schema document. Alternatively, it is possible for a single XML instance document to be valid with respect to multiple RELAX NG schema documents.

Here are some of the key features of RELAX NG:

  • It's simple and easy to learn.

  • It uses pattern-based grammar with a strong mathematical foundation.

  • It has two different syntaxes: XML syntax and compact syntax.

  • It supports XML Schema datatypes.

  • It supports user-defined datatypes.

  • It supports XML namespaces.

  • It's highly composable.

  • Elements and attributes are treated the same.

RELAX NG is a normalized grammar based on James Clark's Tree Regular Expression for XML (TREX), and Makoto Murata's Regular Language description for XML (RELAX). Because RELAX NG was created after DTDs and XML Schemas, the authors were able to address many of the problems in the earlier schema languages. They were able to remove the complexity associated with W3C XML Schemas while embracing some of its features. Additionally, the authors based RELAX NG on strong mathematical models. Having such models simplifies validator development and enables schema authors to make mathematical assertions about their schemas. XML Schema is the most widely supported validation technology, ...

Get Beginning XML, 4th Edition 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.