次の方法で共有


<xsd:union> 要素

複数の simpleType 定義のコレクションを定義します。

<union
  id = ID 
  memberTypes = List of QNames 
  {any attributes with non-schema Namespace}...>
Content: (annotation?, (simpleType*))
</union>

属性

  • id
    この要素の ID。id の値は ID 型である必要があり、この要素を含んでいるドキュメント内で一意である必要があります。

    省略可能です。

  • memberTypes
    組み込みデータ型の名前またはこのスキーマ (または指定した名前空間によって示される他のスキーマ) に定義されている simpleType 要素の名前のリスト。union 要素を含む simpleType 要素は、memberTypes 値によって指定される単純型から派生します。memberTypes 内の値は、修飾名 (QNames) である必要があります。

    単純型の共用体定義では、単純型のリストは、memberTypes (それ自体が単純型のリスト) のコンテンツと union 要素の下の各 simpleType 子要素定義のコンテンツの共用体です。このトピックの終わりにある 2 つ目の例を参照してください。

    memberTypes 属性は、list 要素の itemType 属性とは対照的な属性です。list 要素の itemType 属性と list 要素の simpleType 子要素は、同時には使用できません。

    省略可能です。

要素情報

出現回数

1 回

親要素

simpleType

コンテンツ

annotationsimpleType

2 つの単純型の union である単純型の例を次に示します。

<xs:attribute name="fontsize">
  <xs:simpleType>
    <xs:union memberTypes="fontbynumber fontbystringname" />
  </xs:simpleType>
</xs:attribute>

<xs:simpleType name="fontbynumber">
  <xs:restriction base="xs:positiveInteger">
    <xs:maxInclusive value="72"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="fontbystringname">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
  </xs:restriction>
</xs:simpleType>

負でないすべての整数と NMTOKEN "unbounded" の共用体である単純型定義の例を次に示します。これは、W3C『XML Schema Part 1: Structures』の仕様のスキーマからの引用です。

<xs:simpleType name="allNNI">
  <xs:annotation>
    <xs:documentation>for maxOccurs</xs:documentation>
  </xs:annotation>
  <xs:union memberTypes="nonNegativeInteger">
   <xs:simpleType>
    <xs:restriction base="xs:NMTOKEN">
     <xs:enumeration value="unbounded"/>
    </xs:restriction>
   </xs:simpleType>
  </xs:union>
 </xs:simpleType>

その他のリソース

詳細については、www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all で公開されている、W3C 勧告『XML Schema Part 1: Structures』を参照してください。

参照

リファレンス

XML スキーマ (XSD) リファレンス
XML スキーマの要素