XML Schema all elements
Definition and Usage
Element specifies that the child elements can appear in any order, each sub-element can occur zero or one time.
Element Information
- Parent element: group, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
grammar
<all
id=ID
maxOccurs=1
minOccurs=0|1
any attributes
>
(annotation?,element*)
</all>
id=ID
maxOccurs=1
minOccurs=0|1
any attributes
>
(annotation?,element*)
</all>
(? Sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times in all elements.)
Attributes | description |
---|---|
id | Optional. The unique identifier of the element. |
maxOccurs | Optional. The maximum number of times the element can occur. The value must be 1. |
minOccurs | Optional. The minimum number of times the element can occur. This value can be an integer of 0 or 1. To specify that this element is optional, the attribute is set to 0. The default value is 1. |
any attributes | Optional. It specifies any other attributes non-schema namespace. |
Example 1
<xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
The example above indicates "firstname" and "lastname" elements can appear in any order, both elements must only appear once!
Example 2
<xs:element name="person">
<xs:complexType>
<xs:all minOccurs="0">
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:complexType>
<xs:all minOccurs="0">
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
The example above indicates "firstname" and "lastname" elements can appear in any order, each element can appear zero or one time!
Complete XML Schema Reference