I am trying to build an XSD for the XML below:
<?xml version="1.0" encoding="UTF-8"?>
<people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="people.xsd">
<student>
<name>John</name>
<study_year>4</study_year>
<study_level>A+</study_level>
<age>21</age>
</student>
<tutor>
<name>Thomas</name>
<salary>2300</salary>
<age>45</age>
<expertise>Math</expertise>
</tutor>
<student>
<name>Mike</name>
<study_level>B-</study_level>
<age>20</age>
<study_year>22</study_year>
</student>
</people>
Currently I have this XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="people">
<xs:complexType>
<xs:sequence maxOccurs="1">
<xs:choice maxOccurs="unbounded">
<xs:element maxOccurs="unbounded" minOccurs="1" name="student">
<xs:complexType>
<xs:sequence maxOccurs="1">
<xs:group ref="person"/>
<xs:element name="study_year"/>
<xs:element name="study_level"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" minOccurs="1" name="tutor">
<xs:complexType>
<xs:sequence maxOccurs="1">
<xs:group ref="person"/>
<xs:element name="salary"/>
<xs:element name="expertise"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="person">
<xs:sequence>
<xs:element name="name"/>
<xs:element name="age"/>
</xs:sequence>
</xs:group>
</xs:schema>
This is just an abstraction of the XSD I am trying to make. I would like to allow any order of the elements within student and tutor. I also need the xs:group because I don't want redundancy.
I have tried to replace the xs:sequence with xs:all, but that isn't valid XSD.
Is it possible to do this with an XSD?
Any help is appreciated!