Latest web development tutorials

XML Schema ประเภทที่ซับซ้อน - เนื้อหาผสม

ประเภทคอมโพสิตผสมอาจมีลักษณะองค์ประกอบและข้อความ


ประเภทที่ซับซ้อนที่มีเนื้อหาแบบผสม

องค์ประกอบ XML, "ตัวอักษร" ที่มีข้อความและองค์ประกอบอื่น ๆ :

<letter>
Dear Mr.<name>John Smith</name>.
Your order <orderid>1032</orderid>
will be shipped on <shipdate>2001-07-13</shipdate>.
</letter>

ต่อไปนี้เค้าร่างประกาศนี้ "ตัวอักษร" องค์ประกอบ:

<xs:element name="letter">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="orderid" type="xs:positiveInteger"/>
<xs:element name="shipdate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>

หมายเหตุ: หากต้องการข้อมูลตัวอักษรจะปรากฏระหว่าง "ตัวอักษร" ขององค์ประกอบย่อยแอตทริบิวต์ผสมจะต้องตั้งค่า "true"<Xs: ลำดับ> tag องค์ประกอบ (ชื่อ OrderID และ SHIPDATE) หมายความว่าความหมายจะต้องปรากฏในลำดับภายใน "ตัวอักษร" องค์ประกอบ

นอกจากนี้เรายังสามารถให้ชื่อสำหรับองค์ประกอบ complexType และปล่อยให้ "ตัวอักษร" ประเภทองค์ประกอบแอตทริบิวต์อ้างอิงชื่อ complexType (โดยวิธีนี้องค์ประกอบหลายอย่างสามารถอ้างถึงชนิดที่ซับซ้อนเดียวกัน):

<xs:element name="letter" type="lettertype"/>

<xs:complexType name="lettertype" mixed="true">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="orderid" type="xs:positiveInteger"/>
<xs:element name="shipdate" type="xs:date"/>
</xs:sequence>
</xs:complexType>