by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)


The grammar and start Elements

In the Russian doll-style, the definition of the root element (in this case, the library element) is used as a container for the whole schema. When you define named patterns, you need a container to embed both the named pattern definitions and the definition of the root element of the named patterns. This definition of the root element, as well as definitions of all the patterns that may be used within it, is what RELAX NG calls a grammar. It uses the grammar element. When you use a grammar element, RELAX NG requires you to explicitly declare the root element or elements, using a start element. An incomplete skeleton of the structure of the schema defining a pattern name-element would thus be:

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
 <start>
  <element name="library">
   .../...
  </element>
 </start>
 <define name="name-element">
  .../...
 </define>
</grammar>

or, using the compact syntax:

grammar {
 name-element = .../...
 start =
  element library {
  .../...
 }
}

In the compact syntax, the grammar pattern is implicit. You can use it, but it isn't required.


This text is released under the Free Software Foundation GFDL.