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.


Order variation as a source of information

Before we move on to text patterns and mixed content, let's think again about the "interleave" pattern. As we have already noted, the fact that these content models are often called "unordered" is misleading. Although no order is required by the schema, the nodes will be ordered in instance documents. The order in which they appear in the document may be significant to the applications.

Going back to our example with first and last names, any application managing names will probably need to know what my first name is and which is my last name. With a little additional effort they can get the information about whether the first name comes before or after the last name in a XML document. The friendliest of these applications may also want to know whether I prefer to be called by my first or last name first. Do we need to add an additional information item to our schema to carry this information when we can just rely on the order of these elements in the instance document?

In other words, defining content using interleave patterns could be seen as degrading the usefulness of a schema because it looks like the information about the order in which the elements were found will be stripped from the document. That isn't a real problem. XML processors will still present all of that order information to your application. In fact, a content model defined with "interleave" patterns allows more combinations than a content model that uses "group" patterns. Thus, with its additional combinations, the interleve patterns can let document creators provide additional information that would otherwise disappear into a fixed structure.

The one downside to using interleave patterns is that the freedom with which they can be used is unfortunately specific to RELAX NG. If you need to insure that it will also be possible to model your vocabulary with a more rigid schema language such as W3C XML Schema, you will often have to restrict the usage of "interleave" patterns in your RELAX NG schemas.


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.