XML Schema union element

การใช้งานและการกำหนด

element ของ union กำหนดชุดของ simpleType ที่กำหนดโดยแนวทาง

ข้อมูลองค์ประกอบ

จำนวนการปรากฏ ครั้ง
องค์ประกอบพ่อ simpleType
องค์ประกอบ annotation、simpleType

วลี

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

(? สัญลักษณ์แสดงว่าองค์ประกอบนี้สามารถปรากฏขึ้นโดยเป็น 0 หรือ 1 ครั้งใน element ของ union )

ข้อมูล คำอธิบาย
id ทางเลือกอื่น ๆ กำหนดข้อกำหนดของ ID ที่เป็นเดียวขององค์ประกอบ
memberTypes ทางเลือกอื่น ๆ กำหนดข้อกำหนดของรายชื่อของประเภทข้อมูลภายในโครงสร้างหรือองค์ประกอบ simpleType
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>