I am looking a way to apply restriction on values of two elements combined with each other. My current schema is:
<xs:simpleType name="CTKOD_EONE">
<xs:restriction base="xs:string">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="3" />
<xs:enumeration value="4" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="CTKOD_ETWO">
<xs:restriction base="xs:string">
<xs:enumeration value="A" />
<xs:enumeration value="B" />
<xs:enumeration value="C" />
<xs:enumeration value="D" />
</xs:restriction>
</xs:simpleType>
<xs:element name="DATA" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="EONE" type="CTKOD_EONE">
<xs:element name="ETWO" type="CTKOD_ETWO">
</xs:all>
</xs:complexType>
</xs:element>
XML example:
<DATA>
<EONE>1</EONE>
<ETWO>C</ETWO>
</DATA>
<DATA>
<EONE>4</EONE>
<ETWO>D</ETWO>
</DATA>
<DATA>
<EONE>2</EONE>
<ETWO>A</ETWO>
</DATA>
<DATA>
<EONE>3</EONE>
<ETWO>B</ETWO>
</DATA>
But in my case each DATA must have a restriction on combination of EONE and ETWO. For example:
1 with C - valid
4 with D - valid
2 with A - valid
3 with B - INVALID!!
Is that possible to have some complex restriction on values of N child elements? Or other way to solve this issue with XSD? Help me please to figure out the possible solution.
It's easy in XSD 1.1 with xs:assert
.
It's impossible in XSD 1.0.