XSD 复合空元素

element ที่ผสมว่างไม่สามารถมีเนื้อหาได้ แต่มีเพียงแค่สมบัติเท่านั้น:

XML element ว่างที่ผสม:

XML element ว่าง:

<product prodid="1345" />

element "product" ดังกล่าวไม่มีเนื้อหาอะไรทั้งสิ้น。เพื่อกำหนดชนิดที่ไม่มีเนื้อหา คุณจะต้องประกาศชนิดที่เพียงแค่มี element ในเนื้อหา แต่ไม่มีการประกาศelementใดๆ ตามนี้:

<xs:element name="product">
  <xs:complexType>
    <xs:complexContent>
      <xs:restriction base="xs:integer">
        <xs:attribute name="prodid" type="xs:positiveInteger"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
</xs:element>

ในตัวอย่างดังกล่าว เราได้กำหนดชนิดที่มีเนื้อหาที่ผสมกัน。เซ็นนาส์ comprehends ชี้ให้เห็นว่าเราตั้งใจจะจำกัดหรือขยายเนื้อหาของชนิดที่ผสมกัน และการจำกัด integer มีความหมายว่ามีสมบัติแต่ไม่มีเนื้อหาตัวเอง

อย่างไรก็ตาม ยังสามารถเขียนข้อความดังกล่าวของ element "product" ในรูปแบบที่มีความย่อยยิ่งขึ้น:

<xs:element name="product">
  <xs:complexType>
    <xs:attribute name="prodid" type="xs:positiveInteger"/>
  </xs:complexType>
</xs:element>

หรือคุณอาจจะให้ชื่อต่อ element ชนิด complexType และกำหนด type ของ element "product" ด้วยการอ้างค่าชื่อ complexType ดังกล่าว (ด้วยวิธีนี้ หลาย element อาจอ้างค่าชนิดที่เป็นร่วมกัน):

<xs:element name="product" type="prodtype"/>
<xs:complexType name="prodtype">
  <xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>