XSD 복합 빈 요소
- 이전 페이지 XSD 요소
- 다음 페이지 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> 요소가 제공하는 신호는, 우리가 특정 복합 타입의 내용 모델을 제한하거나 확장할 계획임을 의미하며, integer 제한은 속성을 선언하지만 어떤 요소 내용도 추가하지 않습니다.
하지만, 이 "product" 요소를 더 촉진적으로 선언할 수도 있습니다:
<xs:element name="product"> <xs:complexType> <xs:attribute name="prodid" type="xs:positiveInteger"/> </xs:complexType> </xs:element>
또는 복합형 요소에 이름을 부여하고, "product" 요소에 type 속성을 설정하여 이 복합형 이름을 참조할 수 있습니다(이 방법을 통해 여러 요소가 동일한 복합형을 참조할 수 있습니다):
<xs:element name="product" type="prodtype"/> <xs:complexType name="prodtype"> <xs:attribute name="prodid" type="xs:positiveInteger"/> </xs:complexType>
- 이전 페이지 XSD 요소
- 다음 페이지 XSD 요소만 포함