XSD - 僅複雜文字元素
複雜文字僅元素只能包含文字和屬性,但不包含內容。請參閱以下示例 −
<marks grade = "A" >90</student>
我們可以使用以下方法聲明覆雜文字僅元素 −
使用 SimpleContent
定義具有 simpleContent 的複雜型別。SimpleContent 可以使用擴充套件/限制元素來增加/減少元素基型別的範圍。使用 type 屬性建立定義複雜型別的元素。
<xs:element name = "marks" type = "marksType"/>
<xs:complexType name = "marksType">
<xs:simpleContent>
<xs:extension base = "xs:integer">
<xs:attribute name = "grade" type = "xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
僅使用 ComplexType
僅使用必需的屬性元素定義複雜型別元素。
<xs:element name = "marks">
<xs:complexType>
<xs:simpleContent>
<xs:extension base = "xs:integer">
<xs:attribute name = "grade" type = "xs:string" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
xsd_complex_types.htm
廣告