XSD Composite Type - Only Elements
- Vorige pagina XSD Empty Element
- Volgende pagina XSD Only Text
The complex type element "only contains elements" is an element that can only contain other elements.
The complex type only contains elements
The XML element, "person", only contains other elements:
<person> <firstname>John</firstname> <lastname>Smith</lastname> </person>
You can define the "person" element like this in the schema:
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
Please note this <xs:sequence>. It means that the defined elements must appear in the order specified above within the "person" element.
Of course, you can also assign a name to the complexType element and let the type attribute of the "person" element refer to this name (if this method is used, several elements can refer to the same complex type):
<xs:element name="person" type="persontype"/> <xs:complexType name="persontype"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complexType>
- Vorige pagina XSD Empty Element
- Volgende pagina XSD Only Text