XML Schema choice要素
完全な XML Schema リファレンスマニュアル
定義と使用法
XML Schema の choice 要素は、宣言内に含まれる
要素情報
- 親要素: group, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
構文
<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
(? 記号は choice 要素内で要素が0回または1回出現し得ることを宣言し、* 記号は要素が0回または複数回出現し得ることを宣言します。)
| 属性 | 説明 |
|---|---|
| id | 任意。この要素の一意のIDを指定します。 |
| maxOccurs | 任意。choice 要素が親要素内に出現できる最大回数を指定します。この値は0以上の整数にすることができます。最大回数に制限を設定したくない場合は、文字列 "unbounded" を使用してください。デフォルト値は1です。 |
| minOccurs | 任意。choice 要素が親要素内に出現できる最小回数を指定します。この値は0以上の整数にすることができます。その any グループをオプションとして指定する場合は、この属性を0に設定してください。デフォルト値は1です。 |
| any attributes | 任意。non-schema 名前空間を持つその他の属性を指定します。 |
例 1
<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>
<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 Schema リファレンスマニュアル その他の拡張機能