I have a XSD document fragment below. When an XML file validates against this schema I wish to ensure that the value in mm:Depot
and mm:Customer/mm:County
are the same and restricted to items in the Location
type.
This can be done in XML Schema 1.1 using the <assert>
tag but I MUST validate against XML Schema 1.0. Is there some neat trick to make this work in 1.0?
<xsd:element name="DeliveryOrder" type="OrderDetails" />
<xsd:complexType name="OrderDetails">
<xsd:sequence>
<xsd:element name="Depot" type="mm:Location" />
<xsd:element name="Customer" type="mm:Customer" maxOccurs="1" minOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="Location">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="OverHere" />
<xsd:enumeration value="OverThere" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Customer">
<xsd:sequence>
<xsd:element name="firstname" type="string" />
<xsd:element name="surname" type="string" />
<xsd:element name="County" type="mm:Location" />
</xsd:sequence>
</xsd:complexType>
What I want to achieve is something like this...
<?xml version="1.0" encoding="UTF-8"?>
<mm:DeliveryOrder xmlns:mm="http://myNamespace/DeliveryOrderSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://myNamespace/DeliveryOrderSchema DeliveryOrder.xsd ">
<mm:Depot>OverThere</mm:Depot>
<mm:Customer>
<mm:firstname>Jane</mm:firstname>
<mm:surname>Doe</mm:surname>
<mm:County>OverThere</mm:County>
</mm:Customer>
</mm:DeliveryOrder>
Note the value OverThere
appears twice.