XML スキーマ choice 要素
完全なXMLスキーマリファレンス
定義と用法
XMLスキーマ choice 要素は、<choice> 宣言に含まれている唯一の要素だけが包含要素内に存在することを可能にします。
要素情報
- 親要素: 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>
(choice 要素内で、? 記号は要素が 0 または 1 回出現できることを宣言し、* 記号は要素がゼロ回以上出現できることを宣言します)
属性 |
説明 |
id |
オプション。 要素へユニークな ID を指定する |
maxOccurs |
オプション。choice 要素が親要素で出現できる最大数を指定する。
値は、任意の数値 >= 0 にすることができる。また、最大数で上限を設定しない場合は、
値 "unbounded" を使用する。デフォルト値は 1 |
minOccurs |
オプション。 choice 要素が親要素で出現できる最小数を指定する。
値は任意の数 >= 0 にすることができる。デフォルト値は 1 |
any attributes |
オプション。非スキーマ名前空間を持つ他の属性を指定する |
例 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>
上記例では、"employee" 要素や "member" の要素のいずれかを含む必要がある
"person" という名前の要素を定義しています。
完全なXMLスキーマリファレンス
|