I have following XML:
<entity>
<category>Foo</category>
<subcategory>Foo1</subcategory>
</entity>
Now i want to have only specific subcategories allowed. I would start with following XSD:
<xs:element name="entity">
<xs:complexType>
<xs:sequence>
<xs:element name="category" type="categories"/>
<xs:element name="subcategory" type="???"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="categories">
<xs:restriction base="xs:string">
<xs:enumeration value="Foo"/>
<xs:enumeration value="Bar"/>
<xs:enumeration value="many other categories"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="fooSubCategories">
<xs:restriction base="xs:string">
<xs:enumeration value="Foo1"/>
<xs:enumeration value="Foo2"/>
<xs:enumeration value="FooN"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="barSubCategories">
<xs:restriction base="xs:string">
<xs:enumeration value="Bar1"/>
<xs:enumeration value="Bar2"/>
<xs:enumeration value="BarN"/>
</xs:restriction>
</xs:simpleType>
now i read about the assert-element in XSD 1.1: XML Restrict based on another element value. XSD 1.1 has also rules as i read.
How would I do that? I tried to expand my subcategory element and insert a xs:choice element but that's not allowed in the specification.