XSD 텍스트만 포함하는 복합 요소
- 이전 페이지 XSD 요소만 포함
- 다음 페이지 XSD 혼합 내용
텍스트만 포함하는 복합 요소는 텍스트와 속성을 포함할 수 있습니다.
텍스트만 포함하는 복합 요소
이 형식은 간단한 내용(텍스트와 속성)만 포함하므로, 이 내용에 simpleContent 요소를 추가해야 합니다. 간단한 내용을 사용할 때, simpleContent 요소 내에서 확장 또는 제한을 정의해야 합니다. 예를 들어:
<xs:element name="某个名称"> <xs:complexType> <xs:simpleContent> <xs:extension base="basetype"> .... .... </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element>
또는:
<xs:element name="某个名称"> <xs:complexType> <xs:simpleContent> <xs:restriction base="basetype"> .... .... </xs:restriction> </xs:simpleContent> </xs:complexType> </xs:element>
힌트:extension 또는 restriction 요소를 사용하여 요소의 기본 간단한 형식을 확장하거나 제한합니다.
이 XML 요소 예제는 "shoesize"로, 단순한 텍스트만 포함하고 있습니다:
<shoesize country="france">35</shoesize>
다음 예제는 내용이 정수로 정의된 복합형을 선언하며, "shoesize" 요소는 "country" 이름의 속성을 가지고 있습니다:
<xs:element name="shoesize"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:integer"> <xs:attribute name="country" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element>
complexType 元소에 이름을 설정할 수 있으며, "shoesize" 요소의 type 속성이 이 이름을 참조하도록 할 수 있습니다.(이 방법을 사용하면 여러 요소가 동일한 복합형을 참조할 수 있습니다):
<xs:element name="shoesize" type="shoetype"/> <xs:complexType name="shoetype"> <xs:simpleContent> <xs:extension base="xs:integer"> <xs:attribute name="country" type="xs:string" /> </xs:extension> </xs:simpleContent> </xs:complexType>
- 이전 페이지 XSD 요소만 포함
- 다음 페이지 XSD 혼합 내용