Organizes content into a group to specify a sequence.
Syntax
<group
maxOccurs="{1 | *}"
minOccurs="{0 | 1}"
order="{one | seq | many}" >
Attributes
maxOccurs
Maximum number of times the group can occur. The following values can be assigned to this attribute.
1 | Occurs at most once. |
* | Unlimited number of occurrences. |
minOccurs
Minimum number of times the group can occur. The following values can be assigned to this attribute.
0 | Not required; the group is optional. |
1 | Must occur at least once. |
order
Constraints on the sequence of elements (and other contained groups) within this group. The following values can be assigned to this attribute.
one | Permits only one instance of each element contained in the group. (This corresponds to the '|' symbol in the document type definition (DTD).) |
seq | Requires the elements in the group to appear in the specified sequence. |
many | Permits the elements in the group to appear (or not appear) in any order. |
The "seq" setting is needed to specify valid sequences. For example, it can be used to specify when a particular sequence such as "x1,y1" or "x2,y2" is valid but no other possible combinations are valid. The "seq" value serves the same role as parentheses in a DTD.
Element Information
Number of occurrences | Unlimited |
Parent elements | ElementType |
Child elements | element, description |
Requires closing tag | Yes. XML Schema is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed. |
Remarks
The order attribute takes the same values as the order attribute of the ElementType element.
The minOccurs and maxOccurs attributes have the default value "1." A group with neither attribute must appear once and only once in a content model.
Examples
The following example demonstrates the "one" setting:
<ElementType name="z" order="one">
<element type="x">
<element type="y">
</ElementType>
The following represents a legal instance of the schema:
<z>
<x/>
<y></y>
</z>
The following example demonstrates the "seq" setting:
<ElementType name="x" order="one">
<group order="seq">
<element type="x1">
<element type="y1">
</group>
<group order="seq">
<element type="x2">
<element type="y2">
</group>
</ElementType>
The following two examples represent legal instances of this schema:
<x>
<x1/>
<y1/>
</x>
and:
<x>
<x2/>
<y2/>
</x>
The following example demonstrates the "many" setting:
<ElementType name="x" content="eltOnly" order="many">
<element type='q'>
<element type='r'>
</ElementType>
The following five examples represent all legal instances for this schema:
<x> </x>
<x> <q> </x>
<x> <r> </x>
<x> <q> <r> </x>
<x> <r> <q> </x>