XML Schema groupElement
Complete XML Schema Reference Manual
Definition and Usage
The group element is used to define groups of elements used in complex type definitions.
Element Information
- Parent element: schema, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
Syntax
id=ID
name=NCName
ref=QName
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(all|choice|sequence)?)
</group>
(The ? sign declares that the group element can occur zero or one time.)
| Attributes | Description |
|---|---|
| id | Optional. Specifies a unique ID for the element. |
| name | Optional. Specifies the name of the group. This name must be a no-colon name (NCName) defined in the XML Namespace specification. Use this attribute only when the schema element is the parent of the group element. In this case, the group is a model group used by complexType, choice, and sequence elements. The name attribute and the ref attribute cannot appear at the same time. |
| ref | Optional. References the name of another group. The ref value must be a QName. The ref can contain a namespace prefix. The name attribute and the ref attribute cannot appear at the same time. |
| maxOccurs | Optional. Specifies the maximum number of times the group element can appear in the parent element. This value can be an integer greater than or equal to zero. To set no limit on the maximum number, use the string "unbounded". The default value is 1. |
| minOccurs | Optional. Specifies the minimum number of times the group element can appear in the parent element. This value can be an integer greater than or equal to zero. The default value is 1. |
| any attributes | Optional. Specifies any other attributes with a non-schema namespace. |
Example 1
The following example defines a group containing a sequence of four elements, and uses this group element in a complex type definition:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="custGroup">
<xs:sequence>
<xs:element name="customer" type="xs:string"/>
<xs:element name="orderdetails" type="xs:string"/>
<xs:element name="billto" type="xs:string"/>
<xs:element name="shipto" type="xs:string"/>
</xs:sequence>
</xs:group>
<xs:element name="order" type="ordertype"/>
<xs:complexType name="ordertype">
<xs:group ref="custGroup"/>
<xs:attribute name="status" type="xs:string"/>
</xs:complexType>
</xs:schema>
Complete XML Schema Reference Manual Other extensions