Question about <unique/>/<keyref/>

Hi,
 
A construct involving a <unique/>/<keyref/> pair is not giving me the
validation behavior that I anticipate.
 
As I read the schema specification, the instance below should NOT validate
against the schema below. However, with the validator that I am using, the
instance DOES validate. 
 
Who's right here: me or the machine?
 
John
======================
John F. Madden
Duke University Medical Center
 
<!--Am I right to think the following instance should be INVALID...?-->

<Root xmlns="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test.xsd">

     <KeyElement KeyField1="1" KeyField2="a"/>

     <KeyElement KeyField1="2" KeyField2="b"/>

     <KeyElement KeyField1="3"/>

     <KeyElement KeyField2="c"/>

     <KeyrefElement KeyrefField1="1" KeyrefField2="a"/>

     <KeyrefElement KeyrefField1="2" KeyrefField2="b"/>

     <KeyrefElement KeyrefField1="3"/>

     <KeyrefElement KeyrefField2="c"/>

     <KeyrefElement KeyrefField1="ThisKeyValueDoesNotExist"/>

     <KeyrefElement KeyrefField2="NeitherDoesThisOne"/>

</Root>

 

 

<!--...if this is the schema I'm validating against...-->

<xs:schema targetNamespace="test" xmlns="test"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

     <xs:element name="Root">

          <xs:complexType>

               <xs:choice maxOccurs="unbounded">

                         <xs:element name="KeyElement" type="KeyElementType"
maxOccurs="unbounded"/>

                         <xs:element name="KeyrefElement"
type="KeyrefElementType" maxOccurs="unbounded"/>

               </xs:choice>

          </xs:complexType>

          <xs:unique name="Uniqueness">

               <xs:selector xpath=".//KeyElement"/>

               <xs:field xpath="@KeyField1"/>

               <xs:field xpath="@KeyField2"/>

          </xs:unique>

          <xs:keyref name="ReferentialIntegrity" refer="Uniqueness">

               <xs:selector xpath=".//KeyrefElement"/>

               <xs:field xpath="@KeyrefField1"/>

               <xs:field xpath="@KeyrefField2"/>

          </xs:keyref>

     </xs:element>

     <xs:complexType name="KeyElementType">

          <xs:complexContent>

               <xs:extension base="xs:anyType">

                    <xs:attribute name="KeyField1" type="xs:string"/>

                    <xs:attribute name="KeyField2" type="xs:string"/>

               </xs:extension>

          </xs:complexContent>

     </xs:complexType>

     <xs:complexType name="KeyrefElementType">

          <xs:complexContent>

               <xs:extension base="xs:anyType">

                    <xs:attribute name="KeyrefField1" type="xs:string"/>

                    <xs:attribute name="KeyrefField2" type="xs:string"/>

               </xs:extension>

          </xs:complexContent>

     </xs:complexType>

</xs:schema>

This email was sent on 1/16/04 at 7:13 PM.

Received on Friday, 16 January 2004 19:17:36 UTC