The group Pattern

Here is the definition of 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, I haven’t specified how the different nodes constituting the character element must 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 previous definition 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 isn’t considered significant by the XML 1.0 specification, the meaning of the group compositor is slightly less straightforward than it appears at first. Here’s the semantic quirk: 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 with 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 that 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. You’ll see later in the chapter that in certain conditions, nodes matching patterns defined outside of a group can be “inserted” in the group.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.232.95