Tip

RELAX NG, the XML Schema alternative

Those who've been knocking around the XML or Web development communities for any length of time have come across the work of James Clark, if not evidence of the man himself. His is a pretty fascinating story, which you can read more about on his bio page.

    Requires Free Membership to View

For the purposes of our discussion, let's just say he's been around the SGML and XML communities since the early 90s and has contributed a substantial and extremely useful body of work. His highlight reel includes an open source SGML parser he wrote in C, acting as technical lead during the development of the XML 1.0 Recommendations, enhancing SGML to make XML a formal subset of SGML, development of expat, "the world's fastest XML parser," co-authoring the XSL submission, editing the XSLT and XPath Recommendations, and last and most relevant, developing TREX, a schema language for XML that pre-dated (and many believe outclasses) XML Schema.

In fact, TREX plus another alternate XML schema language named RELAX, gave rise to RELAX NG (where NG stands for Next Generation), which is an OASIS development project and is now also enshrined as ISO/IEC standard 19757-2. This probably explains why most of Clark's recent work centers around RELAX NG and includes an open source validator for that markup language (Jing), a tool for converting XML DTDs into RELAX NG (DTDinst), a Java program that translates RELAX NG schemas into other formats (Trang) and a new XML mode for GNU Emacs that performs incremental XML parsing and does RELAX NG validation.

Why bother with RELAX NG when there's XML Schema, a W3C recommendation also available? Three short answers explain why this markup language is worth digging into:

  • The language is designed to be simple and easy to learn, which many would observe is not the case for XML Schema.
  • The language includes both an XML syntax and a compact non-XML syntax. It also supports XML namespaces and does not change the information set of any XML document it touches.
  • It works with XML Schema Datatypes (just as does XML Schema itself) and can draw on the expressive power of that markup language.

All of this goes to explain why RELAX NG is so widely used and why it still enjoys a reputation as an attractive, if not compelling, alternative to XML Schema to this very day. ISO Standard status doesn't hurt much, either, especially in Europe where this kind of official seal of approval often means more than it does in the states.

You can dig deeply into RELAX NG, through many avenues (including the aforementioned bio page for Clark himself), but the following sites offer outstanding entry points:

  • RELAX NG home page: though it hasn't been updated since September 2003, you'll still find lots of useful stuff here, including pointers to OASIS and ISO that do include completely current information.
  • As is so often the case with XML topics, Robin Cover's CoverPages provide excellent info and pointers to RELAX NG topics as well. Visit the RELAX NG page for more information.
  • Various items of interest are available at the ISO Web site, including the ISO/IEC19757-2:2003 home page and their download page for Freely Available Standards (you'll find two hits there related to RELAX NG).
  • Eric van der Vlist has also written a good book for O'Reilly Media entitled RELAX NG (July 2003, ISBN: 0596004214) that covers both the XML and compact syntax approaches quite well, and digs into best practices and integration with external type libraries and XML Schema regular expressions. It also provides lots of examples and illustrations that readers will find useful and illuminating.

Those who need to build schemas for XML documents or document collections and who've been frustrated by XML Schema may find RELAX NG preferable. Check it out, and you may come to share this viewpoint.

About the author

Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. Among his many XML projects is the 2002 Sybex book XML Schemas, which he co-authored with Chelsea Valentine and Lucinda Dykes (ISBN: 0792140459). E-mail Ed at etittel@techtarget.com with comments, questions or suggested topics or tools for review.


This was first published in October 2006

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.