- From: George Cristian Bina <george@oxygenxml.com>
- Date: Mon, 14 Jan 2013 15:16:20 +0200
- To: xmlschema-dev@w3.org
Hi all,
I have problems identifying the relevant parts of the XML Schema spec
that apply to the following example. There is a key defined on the
"child" element selecting the "element/@id" attribute and a key
reference defined on the "parent" element that specifies that
"test/@ref" points to "child/element/@id" attributes:
<?xml version="1.0" encoding="UTF-8"?>
<parent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test.xsd">
<child>
<element id="a1"/>
<element id="a2"/>
</child>
<child>
<element id="a1"/>
<element id="a4"/>
</child>
<test ref="a2"/>
<test ref="a1"/>
</parent>
test.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="parent">
<xs:complexType>
<xs:sequence>
<xs:element name="child" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="element">
<xs:complexType>
<xs:attribute name="id" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="k">
<xs:selector xpath="element"/>
<xs:field xpath="@id"/>
</xs:key>
</xs:element>
<xs:element name="test" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ref"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:keyref name="kr" refer="k">
<xs:selector xpath="test"/>
<xs:field xpath="@ref"/>
</xs:keyref>
</xs:element>
</xs:schema>
Xerces seems to discard all the key defined on "child" elements except
the ones defined on the last "child" element, in the example only the
"a1" and "a4" values are used when the keyref is checked.
Saxon EE keeps all the key values, each set on its key space (that is
each "child" element) and it triggers an error on the reference to a key
that is defined in both "child" elements, the reference to "a1".
My feeling is that Xerces is wrong and Saxon is correct but as I
mentioned I cannot identify in the specification the relevant sections
for this situation.
Here there are the errors reported by Saxon
System ID: /Users/george/Documents/test/validation/instance1.xml
Main validation file: /Users/george/Documents/test/validation/instance1.xml
Schema: /Users/george/Documents/test/validation/test.xsd
Engine name: Saxon-EE 9.4.0.6
Severity: fatal
Description: More than one referenced value found for keyRef {kr}
"a1"
Start location: 9:27
System ID: /Users/george/Documents/test/validation/instance1.xml
Main validation file: /Users/george/Documents/test/validation/instance1.xml
Schema: /Users/george/Documents/test/validation/test.xsd
Engine name: Saxon-EE 9.4.0.6
Severity: fatal
Description: More than one referenced value found for keyRef {kr}
"a1"
Start location: 10:36
System ID: /Users/george/Documents/test/validation/instance1.xml
Main validation file: /Users/george/Documents/test/validation/instance1.xml
Schema: /Users/george/Documents/test/validation/test.xsd
Engine name: Saxon-EE 9.4.0.6
Severity: fatal
Description: More than one referenced value found for keyRef {kr}: "a1"
Start location: 5:0
and here it is the error reported by Xerces:
System ID: /Users/george/Documents/test/validation/instance1.xml
Main validation file: /Users/george/Documents/test/validation/instance1.xml
Schema: /Users/george/Documents/test/validation/test.xsd
Engine name: Xerces
Severity: error
Description: cvc-identity-constraint.4.3: Key 'kr' with value 'a2' not
found for identity constraint of element 'parent'.
Start location: 14:10
URL: http://www.w3.org/TR/xmlschema-1/#cvc-identity-constraint
Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Received on Monday, 14 January 2013 13:16:46 UTC