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.
Table of Contents
Although the schema shown in the previous chapter was simple, its XML representation was rather verbose. This is neither surprising nor uncommon for XML vocabularies. In fact it conforms to the basic principles of XML, a Recommendation whose design goals state that "XML documents should be human-legible and reasonably clear" and that "terseness in XML markup is of minimal importance". Our schema is a good example of a document which is "human-legible and reasonably clear" and is definitely not terse!
The principal goal of RELAX NG's XML syntax is to provide a serialization of Relax NG schemas which can be processed by computers using standard XML toolkits. To make it easier for people to read and write RELAX NG schemas, however, James Clark introduced a second syntax which is strictly equivalent to the XML syntax, a compact syntax which is more concise. The compact syntax has been published as an official OASIS RELAX NG committee specification but has not yet been submitted to ISO.
RELAX NG processors are free to support this compact syntax, but they are not required to do so. If a RELAX NG processor doesn't support the compact syntax, then users can translate the XML syntax to and from the compact syntax using existing translators. Since these two forms are strictly equivalent, there is no loss of information during translation. Even comments and annotations (which will be presented in Chapter 13: Annotating Schemas) are preserved in the process.
Note | |
---|---|
Syntactical details of XML such as entity references or processing instructions which are lost when the XML syntax is translated into the compact syntax, but this is a limitation of the XML processing architecture rather than a limitation of RELAX NG itself. |
We'll see that compact syntax is built on a mix of concepts borrowed from the definition of structures in programming languages, notations from XML DTDs, and RELAX NG patterns. Element and attribute patterns look like Java declarations, with their curly brackets preceded by a reserved word, (element or attribute) their RELAX NG pattern name. Optional, one or more and zero or more are represented by DTD qualifier suffixes (? for optional, + for one or more and * for zero or more).
The compact syntax is extremely easy to use, especially (but not only if you've ever worked with DTDs. You'll find the syntax to be intuitive, simple and familiar before the end of this book. In this chapter, we'll explore the part of the compact syntax which map to the RELAX NG patterns already discussed in the previous chapter. Later chapters will introduce new components for the compact syntax along with their more verbose XML equivalents.
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.