XSD 복합 공백 요소

비어 있는 복합 요소는 내용을 포함할 수 없으며, 속성만을 포함할 수 있습니다.:

복합 비어 있는 요소:

비어 있는 XML 요소:

<product prodid="1345" />

위의 "product" 요소에는 내용이 없습니다. 내용이 없는 유형을 정의하려면, 내용에 단지 요소만을 포함할 수 있는 유형을 선언해야 하지만, 실제로는 어떤 요소도 선언하지 않습니다. 예를 들어, 이렇게 합니다.:

<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>

위의 예제에서는 복합 내용을 가진 복합 유형을 정의했습니다. completenessElement 요소가 제공하는 신호는, 우리가 복합 유형의 내용 모델을 제한하거나 확장할 의도이며, integer 제한은 속성을 선언하지만 요소 내용을 추가하지 않습니다.:

그러나, 이 "product" 요소를 더 효율적으로 선언할 수도 있습니다.:

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

하나의 complexType 요소에 이름을 부여하고, "product" 요소에 type 속성을 설정하여 이 complexType 이름을 참조할 수 있습니다.(이 방법을 통해 여러 요소가 동일한 복합 유형을 참조할 수 있습니다.):

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