XML Schema choice
Element
Definition and Usage
The choice
element in XML Schema allows only one of the elements contained within it.
Element Information
- Parent elements: group, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
Syntax
(? symbol declares that the element can occur zero or one time within the choice element, * symbol declares that the element can occur zero or more times.)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element. |
maxOccurs | Optional. Specifies the maximum number of times the choice element can appear within its parent element. The value can be an integer greater than or equal to zero. Use the string "unbounded" if no limit is desired. The default value is 1. |
minOccurs | Optional. Specifies the minimum number of times the choice element can appear within its parent element. The value can be an integer greater than or equal to zero. Set this attribute to zero to make the any group optional. The default value is 1. |
any attributes | Optional. Specifies any other attributes with non-schema namespaces. |
Example 1
The above example defines that the "person" element must contain either an "employee" element or a "member" element.