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>
위의 예에서 우리는 복잡한 내용을 가진 복잡한 유형을 정의합니다. complexContent 요소는 우리가 복합 유형의 콘텐츠 모델을 제한하거나 확장하려는 신호이며 정수 제한은 하나의 속성을 선언하지만 요소 콘텐츠를 도입하지 않습니다.
그러나 다음과 같이 "product" 요소를 더 간결하게 선언할 수 있습니다.
<xs:element name="product">
<xs:complexType>
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
또는 complexType 요소에 이름을 지정하고 "product" 요소가 complexType의 이름을 참조하는 유형 속성을 갖도록 할 수 있습니다(이 방법을 사용하는 경우 여러 요소가 동일한 복합 유형을 참조할 수 있음).
<xs:element name="product" type="prodtype"/>
<xs:complexType name="prodtype">
<xs:attribute name="prodid" type="xs:positiveInteger"/>
</xs:complexType>