องค์ประกอบ XML Schema complexContent
ความหมายและการใช้งาน
องค์ประกอบ complexContent กำหนดส่วนขยายหรือข้อ จำกัด ในประเภทที่ซับซ้อน (ที่มีเนื้อหาผสมหรือมีองค์ประกอบเท่านั้น)
องค์ประกอบข้อมูล
- องค์ประกอบหลัก: complexType
ไวยากรณ์
<complexContent
id=ID
mixed=true|false
any attributes
>
(annotation?,(restriction|extension))
</complexContent>
id=ID
mixed=true|false
any attributes
>
(annotation?,(restriction|extension))
</complexContent>
(ใช่หรือไม่ลงบอกว่าองค์ประกอบที่สามารถเกิดขึ้นได้เป็นศูนย์หรือหนึ่งครั้งภายในองค์ประกอบ complexContent.)
属性 | 描述 |
---|---|
id | 可选。规定该元素的唯一的 ID。 |
mixed | 可选。规定是否允许字符数据出现在该 complexType 元素的子元素之间。 默认值为 false。 |
any attributes | 可选。规定带有 non-schema 命名空间的任何其他属性。 |
ตัวอย่างที่ 1
ตัวอย่างต่อไปนี้มีประเภทที่ซับซ้อน "fullpersoninfo" พิมพ์ที่ซับซ้อนนี้โดยการขยายที่มีสามองค์ประกอบเพิ่มเติมที่สืบทอดมาจากที่อื่นประเภทประเภทที่ซับซ้อน "personinfo" มาจาก:
<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
ในตัวอย่างข้างต้น "ลูกจ้าง" องค์ประกอบที่จะต้องมีองค์ประกอบต่อไปนี้ในการสั่งซื้อ: "FirstName", "นามสกุล", "อยู่", "เมือง" และ "ประเทศ"
XML Schema สมบูรณ์อ้างอิง