Order Variation as a Source of Information
Before moving on to text patterns and mixed content, the
interleave
pattern deserves more attention. As
already noted, calling these content models 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 can be significant to the applications.
Going back to the example of first and last names: any application managing names will need to know which is a first name and which is a 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 might also want to know whether you prefer to be called by your first or last name first. Do you need to add an additional information item to the schema to carry this information when you could just rely on the order of these elements in the instance document?
In other words, defining content using interleave
patterns can 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 the 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 ...
Get RELAX NG now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.