Relax NG

The educational technology and digital learning wiki
Revision as of 19:49, 22 December 2006 by Daniel K. Schneider (talk | contribs) (→‎Definition)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


RELAX NG is an XML Schema language that represents a sort of compromise between the simplicity of DTDs and the complexity of W3C XML Schema.

According to the RELAX NG home page, its key features are that it:

  • is simple
  • is easy to learn
  • has both an XML syntax and a compact non-XML syntax
  • does not change the information set of an XML document
  • supports XML namespaces
  • treats attributes uniformly with elements so far as possible
  • has unrestricted support for unordered content
  • has unrestricted support for mixed content
  • has a solid theoretical basis
  • can partner with a separate datatyping language (such W3C XML Schema Datatypes)

The language

  • RELAX NG exists in two syntactic versions, an XML syntax and a short syntax.


Copied from the Clark and Murato (2001) RELAX NG Tutorial.

Copyright © The Organization for the Advancement of Structured Information Standards [OASIS] 2001. All Rights Reserved.

This section and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works.

Consider a simple XML representation of an email address book:

   <name>John Smith</name>
   <name>Fred Bloggs</name>

The DTD would be as follows:

<!DOCTYPE addressBook [
<!ELEMENT addressBook (card*)>
<!ELEMENT card (name, email)>
<!ELEMENT email (#PCDATA)>

A RELAX NG pattern for this could be written as follows:

<element name="addressBook" xmlns="">
   <element name="card">
     <element name="name">
     <element name="email">


  • Trang: multi-format schema converter based on RELAX NG. Trang supports the following languages: RELAX NG (both XML and compact syntax), XML 1.0 DTDs, W3C XML Schema. A schema written in any of the supported schema languages can be converted into any of the other supported schema languages, except that W3C XML Schema is supported for output only, not for input. Trang can also infer a schema from one or more example XML documents. Trang aims to produce human-understandable schemas; it tries to preserve all aspects of the input schema that may be significant to a human reader, including the definitions, the way the schema is divided into files, annotations and comments. Uses Jing. Implemented in Java. Written by James Clark. Open source (BSD license).
  • There was also a good converter from SUN, but SUN has well know trouble for keeping names and URLs in place ;)



  • Clark, James and Murata, Makoto (2001), RELAX NG Tutorial, HTML
  • Clark, James and Murata, Makoto (2001), RELAX NG Specification, HTML
  • Eric van der Vlist (2002), Relax NG, Compared,, HTML