Closed cpfaff closed 8 years ago
This allows for better reuse of components. The schema first defines all elements and attributes and then uses references to build up complex type elements. An example for a generic list:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="item" type="xs:string"/> <xs:attribute name="of" type="listType"/> <xs:element name="list"> <xs:complexType> <xs:sequence> <xs:element ref="item"/> </xs:sequence> <xs:attribute ref="listType"/> </xs:complexType> </xs:element> <xs:simpleType name="listType"> <xs:restriction base="xs:string"> <xs:enumeration value="organisms"/> <xs:enumeration value="locations"/> </xs:restriction> </xs:simpleType> </xs:schema>
This allows for better reuse of components. The schema first defines all elements and attributes and then uses references to build up complex type elements. An example for a generic list: