Hi all,
I have an XML in which i need to validate the attribute values based on another attribute value of the same tag.
For Example
-
<Employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
-
<Emp>
-
<Column name="EName">Albert</Column>
-
<Column name="Age">27</Column>
-
<Column name="Dept">105</Column>
-
</Emp>
-
</Employees>
-
Question:
In the above under Employees / Emp / Column, if the attribute "name" has the value "Dept" then the value of the tag should be 105 or 106 or 107
Can anybody throw some light on how to achieve this through XSD. Any help is highly appreciated
I have the below XSD generated though XMLSpy
-
<?xml version="1.0" encoding="UTF-8"?>
-
<!--W3C Schema generated by XMLSpy v2008 rel. 2 (http://www.altova.com)-->
-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
<xs:element name="Column">
-
<xs:complexType>
-
<xs:simpleContent>
-
<xs:extension base="ST_Column">
-
<xs:attribute name="name" use="required">
-
<xs:simpleType>
-
<xs:restriction base="xs:string">
-
<xs:enumeration value="Age"/>
-
<xs:enumeration value="Dept"/>
-
<xs:enumeration value="EName"/>
-
</xs:restriction>
-
</xs:simpleType>
-
</xs:attribute>
-
</xs:extension>
-
</xs:simpleContent>
-
</xs:complexType>
-
</xs:element>
-
<xs:simpleType name="ST_Column">
-
<xs:restriction base="xs:string">
-
<xs:enumeration value="105"/>
-
<xs:enumeration value="27"/>
-
<xs:enumeration value="Albert"/>
-
</xs:restriction>
-
</xs:simpleType>
-
<xs:element name="Employees">
-
<xs:complexType>
-
<xs:sequence>
-
<xs:element ref="Emp" maxOccurs="unbounded"/>
-
</xs:sequence>
-
</xs:complexType>
-
</xs:element>
-
<xs:element name="Emp">
-
<xs:complexType>
-
<xs:sequence>
-
<xs:element ref="Column" maxOccurs="unbounded"/>
-
</xs:sequence>
-
</xs:complexType>
-
</xs:element>
-
</xs:schema>
-
Thanks
Naga