- XSD - Home
- XSD - Overview
- XSD - Syntax
- XSD - Validation
- XSD - Simple Types
- XSD - Complex Types
- XSD - String
- XSD - Date Time
- XSD - Numeric
- XSD - Miscellaneous
- XSD Useful Resources
- XSD - Quick Guide
- XSD - Useful Resources
- XSD - Discussion
Selected Reading
XSD - Complex Text Only Element
Complex Text-only Element can only have text and attribute, but no content. See the following example −
<marks grade = "A" >90</student>
We can declare Complex Text-only elements using the following methods −
Use SimpleContent
Define complexType with simpleContent. SimpleContent can use extension/restriction element to increase/reduce scope of base type of the element. Create an element of defined complexType using type attribute.
<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>
Use ComplexType alone
Define an element of complexType with the required attribute element only.
<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
Advertisements