I am trying to create a schema definition using XSD 1.1 in which outcome of one element is dependent on other. For example, I have drop-down for list of countries and list of states for each country. When a person selects a country, only the states of that country can be selected. The pseudo-code of what I am trying to attain looks something like this.
<xs:schema xmlns:ie="http://www.interviewexchange.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="country">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="USA" />
<xs:enumeration value="UK" />
<xs:enumeration value="India" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="state">
<xs:simpleType>
<xs:restriction base="xs:string">
<assert test="if (country eq 'USA')">
<xs:enumeration value="MA" />
<xs:enumeration value="AR" />
<xs:enumeration value="NY" />
</assert">
<assert test="if (country eq 'India')">
<xs:enumeration value="AP" />
<xs:enumeration value="TN" />
<xs:enumeration value="MP" />
</assert">
</xs:restriction>
</xs:simpleType>
</xs:element>
Please suggest me whether I am following the right approach, If I am following the right approach, can anyone give me the code of how this restriction can be attained? Thanks in Advance...