Table of Contents
Relax NG is a schema language, that is, it defines an XML document type. The reader is assumed to be familiar with these concepts:
XML, the Extensible Markup Language. For more information see the TCC Help System page for XML.
The difference between a well-formed XML document and a valid one. The difference is that a well-formed document need only follow the general rules for XML, while a valid file must conform to a schema as well as being well-formed.
Indeed, the whole point of a schema is to provide a way to mechanically validate the structure of an XML file.
XML has a variety of ways to express a schema. To understand why this is, and why we recommend RNC, here is a brief history of the Schema Wars:
Historically, the first way to express a schema for an XML document type was through a Document Type Definition (DTD), which is part of the XML standard.
Such schemas are universally supported today, but the DTD syntax is limited in what it can express. Many users also wanted to see more features for the validation of common content types (e.g., floating point numbers or URLs). Also, because of XML's heritage in SGML, DTD schemas use their own syntax, which does not resemble XML.
XML Schema is a W3C Recommendation. There are three parts to it:
Part 0: Primer is an introductory section.
Part 1: Structures covers XML Schema's method for describing the structure of documents. A schema written in this method is itself a valid XML document, which addresses one of the objections to DTDs. However, it is quite complex.
Part 2: Datatypes proposed a large, rich set of datatypes to assist applications in validating content.
Relax NG was a reaction against the complexity of XML Schema. Written by James Clark and Makoto Murata, this standard is maintained at Organization for the Advancement of Structured Information Standards (OASIS), an open-source standards organization. It is being developed as an ISO standard, ISO/IEC 19757-2.
The author considers Relax NG to be a nearly perfect schema language. It has sufficient structural complexity to handle a huge range of applications, but is easy to learn. Most implementations use Part 2 of the XML Schema work to provide a rich and standardized set of datatypes. Like XML Schema, a Relax NG schema is itself a valid XML document.
The author feels that although the XML syntax for Relax NG is “almost perfect,” James Clark made a quantum improvement when he invented RNC (Relax NG Compact Syntax). Although an RNC schema is not an XML data type, it is much less verbose.
The document you are now reading is a compact reference to RNC syntax. The author recommends these documents for full details: