CTO Articles

Home > News > CTO Articles

IT World
XML IN PRACTICE --- 01/10/2002

Relaxing into 2002

By Sean Mc Grath

RELAX NG is a blend of simplicity and pragmatism aimed at providing a validation system for XML documents. By separating the validation from other XML processing features, RELAX NG keeps DTDs from doing more than they are intended to do.

From time-to-time, a markup technology comes along without much fanfare that really changes the way we think about and build XML systems. The SAX API, developed under the tutelage of David Megginson on the XML-DEV mailing list, springs to mind. Without a big brouhaha or marketing budget, without the imprimatur of any august institution or consortium, SAX has quietly become an indispensable part of the XML application development landscape.

I strongly suspect that RELAX NG <http://www.RELAXNG.org>http://www.RELAXNG.org is following in the footsteps of SAX. SAX was a humble blend of simplicity and pragmatism aimed at providing an event-oriented API for XML processing. Similarly, RELAX NG is a humble blend of simplicity and pragmatism aimed at providing a validation system for XML documents.

RELAX NG schemas are themselves XML documents. Now those of you who work with XSLT know that can be a mixed blessing. On one hand, you can throw all your XML processing tools at them; on the other hand, they can be somewhat legibility challenged.

RELAX NG is a pure delight in this regard, being truly readable after an hour or two of practice. Furthermore, you can intermingle your own markup at will into a RELAX NG schema, which makes adding your own annotations for documentation and module maintenance very simple. Anyone familiar with DTDs that wish to play around with Relax should get DTDinst <http://www.thaiopensource.com/dtdinst/>www.thaiopensource.com/dtdinst/, a Java based tool that converts DTDs into RELAX NG notation.

RELAX NG focused on validation; it does not concern itself with modifying the validated document in any way. DTDs allow you to do that, particularly by using default attribute values. This and some other "omissions" from RELAX NG are, in fact, improvements. DTDs suffer from doing more than specify validation rules; they also get involved in conditional inclusion, macro expansion, and data-typing to name but three. RELAX NG leaves these out, finally creating a clean separation between validation and all these other XML processing features that can be -- as they should be -- implemented in separate layers.

The conciseness and remarkable brevity (given its XML syntax) of RELAX NG reminds me of the phrase, variously attributed to Shaw, Russell, and Pascal: "Please excuse the length of this letter; I do not have time to be brief.". The designers of RELAX NG (principally James Clark and MURATA Makoto) have taken the time to be brief. The syntax is clearly the result of a lot of thought and effort.

Most impressive of all is the fact that this combination of brevity and power is not at the expense of formalism and rigor, which underlies RELAX NG in abundance. The full details are available on the <http://www.oasis-open.org/committees/relax-ng/spec-20011203.html>Oasis site where work on RELAX NG continues.


Sean is co-founder and Chief Technology Officer of Propylon and is an industry–recognised XML expert.