- From: Kevin Burges <xmldude@burieddreams.com>
- Date: Tue, 11 Dec 2001 12:27:01 +0000
- To: Jeni Tennison <jeni@jenitennison.com>
- CC: xmlschema-dev@w3.org
Jeni,
>> 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
wrong:
"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:
[document]
<Root xsi:noNamespaceSchemaLocation="\keyTest.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Form FormID="FORM_1"/>
<IDs>
<Form ID="FORM_1"/>
</IDs>
</Root>
[Schema]
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="Form" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="FormID" type="xs:IDREF" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="IDs">
<xs:complexType>
<xs:sequence>
<xs:element name="Form" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ID" type="xs:ID" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="FormKey">
<xs:selector xpath="IDs/Form"/>
<xs:field xpath="@ID"/>
</xs:key>
<xs:keyref name="Form_FormKeyRef" refer="FormKey">
<xs:selector xpath="Form"/>
<xs:field xpath="@FormID"/>
</xs:keyref>
</xs:element>
</xs:schema>
Received on Tuesday, 11 December 2001 07:31:45 UTC