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>