Mixed compound types can contain attributes, elements, and text. The XML element, “letter”, contains text and other elements: The following schema declares the “letter” element: 注意: In order for character data to appear between children of “letter”, the mixed property must be set to “true”. The < xs:sequence > tags (name, orderid, and shipdate) mean that the defined elements must appear within the “letter” element in turn. We can also give a name to the complexType element and have the type attribute of the “letter” element refer to the name of complexType (in this way, several elements can refer to the same compound type):Composite types with mixed content ¶
<letter>
Dear Mr.<name>John Smith</name>.
Your order <orderid>1032</orderid>
will be shipped on <shipdate>2001-07-13</shipdate>.
</letter>
<xs:element name="letter">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="orderid" type="xs:positiveInteger"/>
<xs:element name="shipdate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="letter" type="lettertype"/>
<xs:complexType name="lettertype" mixed="true">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="orderid" type="xs:positiveInteger"/>
<xs:element name="shipdate" type="xs:date"/>
</xs:sequence>
</xs:complexType>