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.


The group pattern

Here we've defined our character element.

     <element name="character">
      <attribute name="id"/>
      <element name="name">
       <text/>
      </element>
      <element name="born">
       <text/>
      </element>
      <element name="qualification">
       <text/>
      </element>
     </element>

In this snippet of the schema, we have not specified how the different nodes composing the character element need to be composed. RELAX NG recognizes that we have used a group compositor. This group compositor is implied in the XML syntax. You can see, in the compact syntax, that it looks like a grouping of words: each component of the compositor is separated by a comma (,):

   element character {
    attribute id {text},
    element name {text},
    element born {text},
    element qualification {text}}

When using the XML syntax, the group compositor may also be explicitly specified, rather than implied. The definition above is strictly equivalent to this one:

     <element name="character">
      <group>
       <attribute name="id"/>
       <element name="name">
        <text/>
       </element>
       <element name="born">
        <text/>
       </element>
       <element name="qualification">
        <text/>
       </element>
      </group>
     </element>

Because the order of attributes is not considered significant by the XML 1.0 specification, the meaning of the group compositor is slightly less straightforward than it appears at first. The semantic quirk goes something like this: the group compositor says, "Check that the patterns included in this compositor appear in the specified order, except for attributes, which are allowed to appear in any order in the start tag."

A last thing to keep in mind about group compositors is that, as we have said about compositors in general, there is no such thing as already grouped elements for the pattern to map to in an instance document. The notion of group is specific to the pattern which belongs only in our schema. (This means that there is no hard border in instance documents to isolate nodes inside a group from nodes outside of the group. We will see later in the chapter, in the section named "Why is it called 'interleave' instead of 'unorderedGroup'?" that in certain conditions nodes matching patterns defined outside of a group can be "inserted" in the group.)


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.