Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1601

Keyref to a key in a different scope

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Later
    • 2.11.0
    • None
    • None

    Description

      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>
      ----------------------------------

      Attachments

        1. keyref2.xsd
          0.6 kB
          Mukul Gandhi
        2. keyref2.xml
          0.1 kB
          Mukul Gandhi
        3. keyref1.xml
          0.1 kB
          Mukul Gandhi
        4. keyref1_2.xsd
          0.8 kB
          Mukul Gandhi
        5. keyref1_1.xsd
          0.8 kB
          Mukul Gandhi

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            octavian.nadolu Octavian Nadolu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment