RELAX NG by Eric van der Vlist will be published by O'Reilly & Associates (ISBN: 0596004214)

You are welcome to use our annotation system to give your feedback.


A simple example:

Let's take a look at our example. Figure�1 shows the book element with its two attributes and four different sub-elements:

With a DTD and, to a lesser extent, with W3C XML Schema, we are stuck defining lists of attributes and elements that we cannot mix or combine. W3C XML Schema has introduced the concept of types, abstract descriptions that have no direct corollary in the contents of XML documents. Types provide descriptions of the contents of elements or attributes, but types still can't be freely combined together. This means that we can split the description of elements into blocks such as those shown in Figure�2 but can only mix the blocks in a limited number of ways.

RELAX NG patterns, however, can freely mix different types of nodes (elements, text and attributes). Figure�3 shows how, if we want to, we can use RELAX NG to split the definition of the book element into a first pattern composed of the attributes id, title, and author, and the element character and then a second pattern composed of the available attribute and the character elements:

The flexibility just demonstrated is not only useful for combining complex patterns. It also maintains simplicity desired by designers of RELAX NG schemas who do not need or want to learn a long list of design limitations which must be checked when they write and combine their schemas.

This generic concept of patterns is powerful enough to replace the specialized containers of DTDs and W3C XML Schema. RELAX NG has no need for (and no notion of) specially reusable components. Elements, attributes, and types are all embedded in patterns. These patterns are the reusable building blocks of RELAX NG. They can be named, reused and even redefined at will, combined through operators to group them or to provide alternatives among them.

The benefit of having non-specialized patterns is increased flexibility. These benefits are similar to those seen in manufacturing: repeatedly using a small number of generic parts to create a unique whole provides more flexibility and a higher number of possible combinations than using more specialized pieces. This works for XML schema languages too.


You are welcome to use our annotation system to give your feedback.
[Annotations for this page]
All text is copyright Eric van der Vlist, Dyomedea. During development, I give permission for non-commercial copying for educational and review purposes. After publication, all text will be released under the Free Software Foundation GFDL.