Latest web development tutorials

XML Schema 복합 빈 요소

속성을 포함 만 포함 할 수 복합 요소의 내용을 비운다.


복합 빈 요소 :

빈 XML 요소 :

<product prodid="1345" />

위의 "제품"아니오 요소의 내용. 어떤 콘텐츠 유형을 정의하지 않으려면, 우리는 형식이 내용 만 요소를 포함 할 수 선언해야하지만, 사실 우리는이 같은 모든 요소를 ​​선언하지 :

<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 요소는 우리가 정의하거나 복합 형식의 콘텐츠 모델을 확장하고자하는 신호를 제공하고, 속성을 정의하는 정수 선언 그러나 어떤 요소의 내용을 소개하지 않습니다.

그러나이 문은 더 컴팩트 한 "제품"요소가 될 수 있습니다

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

또는 당신은 complexType을 요소에 이름을 부여 할 수 있으며, 다음 (여러 요소가 같은 복합 유형을 참조 할 수 있습니다이 방법을 사용하여) type 속성 "제품"을 설정하고이 complexType에 요소 이름을 참조 :

<xs:element name="product" type="prodtype"/>

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