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)
- RELAX NG exists in two syntactic versions, an XML syntax and a short syntax.
Copied from the Clark and Murato (2001) RELAX NG Tutorial.
Consider a simple XML representation of an email address book:
<addressBook> <card> <name>John Smith</name> <email>firstname.lastname@example.org</email> </card> <card> <name>Fred Bloggs</name> <email>email@example.com</email> </card> </addressBook>
The DTD would be as follows:
<!DOCTYPE addressBook [ <!ELEMENT addressBook (card*)> <!ELEMENT card (name, email)> <!ELEMENT name (#PCDATA)> <!ELEMENT email (#PCDATA)> ]>
A RELAX NG pattern for this could be written as follows:
<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> <zeroOrMore> <element name="card"> <element name="name"> <text/> </element> <element name="email"> <text/> </element> </element> </zeroOrMore> </element>
- 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, xml.com, HTML