Octavian Nadolu created XERCESJ-1601:
----------------------------------------

             Summary: Keyref to a key in a different scope
                 Key: XERCESJ-1601
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1601
             Project: Xerces2-J
          Issue Type: Bug
          Components: XML Schema 1.1 Structures
    Affects Versions: 2.11.0
            Reporter: Octavian Nadolu
            Priority: Minor


If I validate the "instance.xml" with the XML Schema "test.xsd" I get the 
following error:
cvc-identity-constraint.4.3: Key 'kr' with value 'a2' not found for identity 
constraint of element 'parent'.
I tested on the xml-schema-1.1-dev branch.

Xerces discards 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.
The schema added below defines a key on the "child" element selecting the 
"element/@id" attribute and a key reference on the "parent" element that 
specifies that "test/@ref" points to "child/element/@id" attributes.

All the keys defined in the "child" elements should be valid, except the ones 
that are duplicates. There is a discussion about this on the XML Schema Dev 
list:
http://lists.w3.org/Archives/Public/xmlschema-dev/2013Jan/0004.html

---- instance.xml------------------
<?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>
----------------------------------

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to