XML Schema ตัวเลือก Element
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์
ความหมายและการใช้งาน
องค์ประกอบตัวเลือก XML Schema อนุญาตให้เพียงหนึ่งองค์ประกอบที่มีอยู่ในการประกาศ <choice> ที่จะอยู่ภายในองค์ประกอบที่มีอยู่
ข้อมูลองค์ประกอบ
- องค์ประกอบหลัก:กลุ่ม ตัวเลือก ลำดับ complexType ข้อจำกัด (ทั้ง simpleContent และ complexContent) ส่วนขยาย (ทั้ง simpleContent และ complexContent)
ไวยากรณ์
<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
(เครื่องหมาย ? ประกาศว่าองค์ประกอบสามารถเกิดขึ้นได้เป็นศูนย์หรือหนึ่งครั้ง และเครื่องหมาย * ประกาศว่าองค์ประกอบนั้นสามารถเกิดขึ้นได้เป็นศูนย์หรือมากกว่าภายในองค์ประกอบตัวเลือก)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
maxOccurs | Optional. Specifies the maximum number of times the choice element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1 |
minOccurs | Optional. Specifies the minimum number of times the choice element can occur in the parent the element. The value can be any number >= 0. Default value is 1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ตัวอย่าง
<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>
ตัวอย่างข้างต้นกำหนดองค์ประกอบชื่อ "บุคคล" ซึ่งต้องมีองค์ประกอบ "พนักงาน" หรือองค์ประกอบ "สมาชิก"
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์