Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML Schema choice Element

XML Schema choice Element


XML Schema Reference Manual Complete XML Schema Reference Manual


Definition and Usage

The XML Schema choice element only allows one of the elements declared in the declaration to appear in the containing element.

Element Information

Syntax

id=ID

maxOccurs=nonNegativeInteger|unbounded

minOccurs=nonNegativeInteger

any attributes

(annotation?,(element|group|choice|sequence|any)*)

(The ? symbol declares that within the choice element, the element can appear zero or one time; the * symbol declares that the element can appear zero or more times.)

property Description
id Optional. Specifies a unique ID for the element.
maxOccurs Optional. Specifies the maximum number of times the choice element can appear in the parent element. The value can be an integer greater than or equal to zero. If you do not want to set any limit on the maximum, use the string "unbounded". The default is 1.
minOccurs Optional. Specifies the minimum number of times the choice element can appear in the parent element. The value can be an integer greater than or equal to zero. To specify that the any group is optional, set this attribute to zero. The default is 1.
any attributes Optional. Specifies any other attributes with a non-schema namespace.

Example 1

  xs:complexType

    xs:choice

      

      

    

  

The example above defines that the "person" element must contain either an "employee" element or a "member" element.


XML Schema Reference Manual Complete XML Schema Reference Manual