W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

Re[2]: Keyref not working in MSXML4 - is it correct?

From: Kevin Burges <xmldude@burieddreams.com>
Date: Tue, 11 Dec 2001 12:27:01 +0000
Message-ID: <1886058469.20011211122701@burieddreams.com>
To: Jeni Tennison <jeni@jenitennison.com>
CC: xmlschema-dev@w3.org

>> I have a very simple keyref set up, as shown in the example below.
>> In XMLSpy 4.1 the document validates fine. In MSXML4 i get an error
>> saying:
>>    The keyref "FORM_1" does not resolve to a key for the Identity
>>    Constraint "FormKey".
>> I can't see anything wrong with the code, so would I be right in
>> thinking there's something wrong in MSXML4 ??

JT> I think so. It looks OK and works OK with XSV and MSV.

I finally got a reply from MS on this. They say that my Keyref was

  "You need to specify the full location path to the Form element in the xpath
   attribute value of the xs:keyref element.

   <xs:keyref name="Form_FormKeyRef" refer="FormKey">
      <xs:selector xpath="Root/Form"/>
      <xs:field xpath="@FormID"/>
   </xs:keyref> "

This change did indeed fix the problem, but it doesn't look to me like
it should work. Given that this Keyref is defined INSIDE the <Root>
element, surely the selector should not itself contain "Root". The Key
element in my example does not have "Root" in it and it works OK. Can
you confirm that I should not need "Root/Form" but simply "Form",
given that this is defined inside <Root>?

Just out of interest I tried "./Form" which also works fine and makes
sense, but "Root/Form" does not. To me, "./Form" says exactly the same
thing as "Form".

Here are the original files I was working with:


<Root xsi:noNamespaceSchemaLocation="\keyTest.xsd"
  <Form FormID="FORM_1"/>
    <Form ID="FORM_1"/>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  <xs:element name="Root">
        <xs:element name="Form" minOccurs="0" maxOccurs="unbounded">
            <xs:attribute name="FormID" type="xs:IDREF" use="required"/>
        <xs:element name="IDs">
              <xs:element name="Form" minOccurs="0" maxOccurs="unbounded">
                  <xs:attribute name="ID" type="xs:ID" use="required"/>
    <xs:key name="FormKey">
      <xs:selector xpath="IDs/Form"/>
      <xs:field xpath="@ID"/>
    <xs:keyref name="Form_FormKeyRef" refer="FormKey">
      <xs:selector xpath="Form"/>
      <xs:field xpath="@FormID"/>
Received on Tuesday, 11 December 2001 07:31:45 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:56 UTC