XML Schema union 要素

定義と使用方法

union 要素は複数のシンプルタイプ定義の集合を定義します。

要素情報

表示回数 一度
親要素 simpleType
内容 annotation、simpleType

文法

<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType*))
</union>

(? シンボルは union 要素内で、この要素は0回または1回表示できます。)

属性 説明
id オプションで、この要素のユニークな ID を指定します。
memberTypes オプションで、schema で定義された組み込みデータタイプまたはシンプルタイプ要素の名前リストを指定します。
any attributes オプションで、non-schema ナーメースペースを持つ他の属性を指定します。

インスタンス

例 1

この例では、二つのシンプルタイプをマージしたシンプルタイプです:

<xs:element name="jeans_size">
  <xs:simpleType>
    <xs:union memberTypes="sizebyno sizebystring" />
  </xs:simpleType>
</xs:element>
<xs:simpleType name="sizebyno">
  <xs:restriction base="xs:positiveInteger">
    <xs:maxInclusive value="42"/>
  </xs:restriction>
</xs:simpleType>
<xs:simpleType name="sizebystring">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
  </xs:restriction>
</xs:simpleType>