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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access