[xml] Question about error reporting when using key / keyref constraints in Schema



Hi, 

I'm using key / keyref constraints in my schema, and in case of error
the behaviour of the report message is not the same with
libxml2-2.6.19 and libxml2-2.6.20 :
- with the 2.6.19 version, the error is carried by the element which
produces the error (which is fine)
- but with the 2.6.20 version, the error is carried by the root
element, so there is no simple way to know which element is incorrect.

Here is my schema :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <xsd:element name="ELEMENTS">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="element" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
        <xsd:element name="element2" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:key name="key">
      <xsd:selector xpath="element"/>
      <xsd:field xpath="."/>
    </xsd:key>
    <xsd:keyref name="keyref" refer="key">
      <xsd:selector xpath="element2"/>
      <xsd:field xpath="."/>
    </xsd:keyref>
  </xsd:element>
</xsd:schema>


And my xml file :
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<ELEMENTS>
<element>test1</element><element2>test</element2>
</ELEMENTS>


- xmllint (version 2.6.19) outputs :
test.xml:3: element element2: Schemas validity error : Element
'element2' [keyRef 'keyref']: No matching key-sequence found.
test.xml fails to validate

- and xmllint (version 2.6.20) ouputs :
test.xml:2: element ELEMENTS: Schemas validity error : Element
'ELEMENTS': No match found for key-sequence ['test'] of key reference
'keyref'.
test.xml fails to validate

Is it a bug or is it a normal / expected behaviour ?

Fabrice



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]