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

Key/Keyref are not validated correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.11.0
    • 2.12.1
    • None

    Description

      The Key/Keyref it is not validated correctly. I tested on the xml-schema-1.1-dev branch.
      You can reproduce it if you validate the XML instance "instance.xml" with the XML Schema "schema.xsd". When you validate the XML file there should be two errors because the "ref" elements refers to invalid keys.

      As a hint, this happens only if the last "person" element does not have a "ref" element as child.

      ---instance.xml----------------
      <personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
      <person id="111">
      <name>name</name>
      <ref>1</ref>
      </person>
      <person id="222">
      <name>name</name>
      <ref>2</ref>
      </person>
      <person id="333">
      <name>name</name>
      </person>
      </personnel>
      ----------------------------------------

      ---schema.xsd-----------------
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <xs:element name="personnel">
      <xs:complexType>
      <xs:sequence>
      <xs:element ref="person" maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>
      <xs:key name="key">
      <xs:selector xpath="person"/>
      <xs:field xpath="@id"/>
      </xs:key>
      <xs:keyref refer="key" name="keyref">
      <xs:selector xpath="person"/>
      <xs:field xpath="ref"/>
      </xs:keyref>
      </xs:element>

      <xs:element name="person">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="ref" type="xs:integer" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="id" type="xs:integer" use="required"/>
      </xs:complexType>
      </xs:element>

      </xs:schema>
      ----------------------------------------

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: