최신 웹 개발 튜토리얼
 

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>