XSD Complexe Typen met Gemengde Inhoud
- Vorige Pagina XSD Alleen Tekst
- Volgende Pagina XSD Indicatoren
Mixed composite types can contain attributes, elements, and text.
Composite type with mixed content
The XML element, "letter", contains text and other elements:
<letter> Dear Mr.<name>John Smith</name>. Your order <orderid>1032</orderid> will be shipped on <shipdate>2001-07-13</shipdate>. </letter>
The following schema declares this "letter" element:
<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>
Note:To allow character data to appear between the subelements of "letter", the mixed attribute must be set to "true". The <xs:sequence> tag (name, orderid, and shipdate) means that the defined elements must appear in sequence within the "letter" element.
We can also give a name to the "complexType" element and let the type attribute of the "letter" element refer to this name of the "complexType" (in this way, several elements can refer to the same composite type):
<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>
- Vorige Pagina XSD Alleen Tekst
- Volgende Pagina XSD Indicatoren