I would like to know if it is possible to write an XML Schema restriction that binds to values of another element.
For example I have XML
In the following XML Schema I would like to restrict the Family value of a person to one of the name attributes of the family elements. This should complain on the last person as the Family name was not listed as a family element.
Is it possible to do so?
Thanks
Mark
For example I have XML
Code:
<people>
<family name="Smith">
<origin>England</origin>
</family>
<family name="Jain">
<origin>India</origin>
</family>
<family name="DelSol">
<origin>Spain</origin>
</family>
<person>
<Given>Mary</Given>
<Family>Smith</Family>
</person>
<person>
<Given>Jorege</Given>
<Family>DelSol</Family>
</person>
<person>
<Given>Sundeep</Given>
<Family>Jain</Family>
</person>
<person>
<Given>John</Given>
<Family>Farley</Family>
</person>
</people>
Is it possible to do so?
Thanks
Mark
Code:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="people">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="family">
<xs:complexType>
<xs:sequence>
<xs:element name="origin" type="xs:string" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="Given" type="xs:string" />
<xs:element name="Family" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Comment