XMLスキーマ選択要素
❮完全なXMLスキーマリファレンス
定義と使用法
XML Schema choice要素では、<choice>宣言に含まれる要素の1つだけが含まれる要素内に存在できます。
要素情報
- 親要素: group、choice、sequence、complexType、restriction(simpleContentとcomplexContentの両方)、extension(simpleContentとcomplexContentの両方)
構文
<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
(?記号は、要素が0回または1回発生する可能性があることを宣言し、*記号は、要素が選択要素内で0回以上発生する可能性があることを宣言します)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
maxOccurs | Optional. Specifies the maximum number of times the choice element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1 |
minOccurs | Optional. Specifies the minimum number of times the choice element can occur in the parent the element. The value can be any number >= 0. Default value is 1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
例
<xs:element name="person">
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>
上記の例では、「person」という名前の要素を定義しています。この要素には、「employee」要素または「member」要素のいずれかが含まれている必要があります。
❮完全なXMLスキーマリファレンス