Next / Previous / Contents / TCC Help System / NM Tech homepage


Describes the Relax NG Compact Syntax, a schema language for specifying XML document types.

This publication is available in Web form and also as a PDF document. Please forward any comments to

Table of Contents

1. What is RNC?
1.1. The schema wars
2. A small example
3. Named patterns: factoring the schema
4. The content patterns
5. The definition patterns
6. The xsd: datatypes
6.1. The basic xsd: types
6.2. Parameters to the xsd: types
6.3. Regular expression syntax for xsd:

1. What is RNC?

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.

1.1. The schema wars

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:

1.1.1. DTD: Document Type Definition

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.

1.1.2. XSchema: The W3C weighs in

XML Schema is a W3C Recommendation. There are three parts to it:

  1. Part 0: Primer is an introductory section.

  2. 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.

  3. Part 2: Datatypes proposed a large, rich set of datatypes to assist applications in validating content.

1.1.3. RNG: Relax NG

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.

1.1.4. RNC: Relax NG Compact Format

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: