J
Joyce
In my schema I have 2 enumerations, let's say, country description and
country code, and I want to use them so I can map each country
description to its precise country code (and no other).
So far I've seen I can define both keys for description and code, but
my XMLs validate even if I choose a wrong pair:
Here are my both enumerations (abbreviated)
<xs:simpleType name="COUNTRYCODE">
<xs:restriction base="xs:int">
<xs:enumeration value="4"/>
<xs:enumeration value="8"/>
<xs:enumeration value="958"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="COUNTRYDESC">
<xs:restriction base="xs:string">
<xs:maxLength value="40"/>
<xs:enumeration value="Afghanistan"/>
<xs:enumeration value="Albania"/>
<xs:enumeration value="Germany"/>
</xs:restriction>
</xs:simpleType>
And I use the "country" element as follows:
<xs:element name="COUNTRY">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="COUNTRYDESC"/>
<xs:element name="value" type="COUNTRYCODE"/>
</xs:sequence>
</xs:complexType>
</xs:element>
How should I define the map and the keys, etc. so that something like
this validates:
<COUNTRY>
<COUNTRYDESC>Germany</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>
But this DOES NOT validate (as it's a wrong description-code pair):
<COUNTRY>
<COUNTRYDESC>Afghanistan</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>
I'll be very grateful for any help!
country code, and I want to use them so I can map each country
description to its precise country code (and no other).
So far I've seen I can define both keys for description and code, but
my XMLs validate even if I choose a wrong pair:
Here are my both enumerations (abbreviated)
<xs:simpleType name="COUNTRYCODE">
<xs:restriction base="xs:int">
<xs:enumeration value="4"/>
<xs:enumeration value="8"/>
<xs:enumeration value="958"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="COUNTRYDESC">
<xs:restriction base="xs:string">
<xs:maxLength value="40"/>
<xs:enumeration value="Afghanistan"/>
<xs:enumeration value="Albania"/>
<xs:enumeration value="Germany"/>
</xs:restriction>
</xs:simpleType>
And I use the "country" element as follows:
<xs:element name="COUNTRY">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="COUNTRYDESC"/>
<xs:element name="value" type="COUNTRYCODE"/>
</xs:sequence>
</xs:complexType>
</xs:element>
How should I define the map and the keys, etc. so that something like
this validates:
<COUNTRY>
<COUNTRYDESC>Germany</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>
But this DOES NOT validate (as it's a wrong description-code pair):
<COUNTRY>
<COUNTRYDESC>Afghanistan</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>
I'll be very grateful for any help!