XML Schema ลำดับ Element
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์
ความหมายและการใช้งาน
องค์ประกอบลำดับระบุว่าองค์ประกอบลูกต้องปรากฏในลำดับ องค์ประกอบย่อยแต่ละรายการสามารถเกิดขึ้นได้ตั้งแต่ 0 ถึงจำนวนครั้งเท่าใดก็ได้
ข้อมูลองค์ประกอบ
- องค์ประกอบหลัก:กลุ่ม ตัวเลือก ลำดับ complexType ข้อจำกัด (ทั้ง simpleContent และ complexContent) ส่วนขยาย (ทั้ง simpleContent และ complexContent)
ไวยากรณ์
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(เครื่องหมาย ? ประกาศว่าองค์ประกอบสามารถเกิดขึ้นได้เป็นศูนย์หรือครั้งเดียวภายในองค์ประกอบลำดับ)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
maxOccurs | Optional. Specifies the maximum number of times the sequence 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 sequence element can occur in the parent element. The value can be any number >= 0. Default value is 1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ตัวอย่าง 1
ตัวอย่างนี้แสดงการประกาศสำหรับองค์ประกอบที่เรียกว่า "personinfo" ซึ่งต้องมีห้าองค์ประกอบต่อไปนี้ตามลำดับ "ชื่อ", "นามสกุล", "ที่อยู่", "เมือง" และ "ประเทศ":
<xs:element name="personinfo">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
ตัวอย่าง 2
ตัวอย่างนี้แสดงการประกาศสำหรับองค์ประกอบที่เรียกว่า "สัตว์เลี้ยง" ที่สามารถมีองค์ประกอบต่อไปนี้ สุนัขและแมวเป็นศูนย์หรือมากกว่าในองค์ประกอบลำดับ:
<xs:element name="pets">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="dog" type="xs:string"/>
<xs:element name="cat" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์