After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 741902 - Multiple error reporting issue while validating document with xsd
Multiple error reporting issue while validating document with xsd
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xmlschema
2.7.6
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2014-12-23 12:15 UTC by Marek Silewicz
Modified: 2021-07-05 13:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Marek Silewicz 2014-12-23 12:15:18 UTC
I have encountered strange issue (not critical) regarding libxml2 xsd validation module.

Please take a look at following output from sample shell script (it useses xmllint to validate document with specially crafted errors (additional attributes and one additional tag) :

[msilewicz@z9 test]$ ./test.sh 
Test with two validation problems (additional attributes)
<?xml version="1.0" encoding="UTF-8"?>
<person id="441a5a57-9225-4021-9cc1-8ce30c43389f">
  <name>John Doe</name>
  <address>
    <line-1>300 BOYLSTON AVE E</line-1>
    <city>TUCSON</city>
    <state>AZ</state>
    <zip-code fake-attr="foo">85705</zip-code>
    <country fake-attr2="foo">US</country>
  </address>
</person>
test.1.xml:8: element zip-code: Schemas validity error : Element 'zip-code', attribute 'fake-attr': The attribute 'fake-attr' is not allowed.
test.1.xml:9: element country: Schemas validity error : Element 'country', attribute 'fake-attr2': The attribute 'fake-attr2' is not allowed.
test.1.xml fails to validate
===========================================================
Test with three validation problems (additional attributes, and additional node)
<?xml version="1.0" encoding="UTF-8"?>
<person id="441a5a57-9225-4021-9cc1-8ce30c43389f">
  <name>John Doe</name>
  <address>
    <foo>BAR</foo>
    <line-1>300 BOYLSTON AVE E</line-1>
    <city>TUCSON</city>
    <state>AZ</state>
    <zip-code fake-attr="foo">85705</zip-code>
    <country fake-attr2="foo">US</country>
  </address>
</person>
test.2.xml:5: element foo: Schemas validity error : Element 'foo': This element is not expected. Expected is ( line-1 ).
test.2.xml fails to validate


First run of xmllint is ok - two errors were reported - that is all.

However second run of xmllint reveals only one problem  - additional tag <foo> - it would be great if two errors reported above (in first run)
would also be revealed.

Schema is as follows :

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="address">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="line-1" type="xs:string"/>
            <xs:element name="line-2" type="xs:string" minOccurs="0"/>
            <xs:element name="city" type="xs:string"/>
            <xs:element name="state" type="xs:string"/>
            <xs:element name="zip-code" type="xs:string"/>
            <xs:element name="country" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" type="xs:string" use="required"/>
  </xs:complexType>
</xs:element>

</xs:schema> 

Content of test.sh script is as follows :

echo "Test with two validation problems (additional attributes)"
xmllint --format --schema test.xsd test.1.xml
echo "==========================================================="
echo "Test with three validation problems (additional attributes, and additional node)"
xmllint --format --schema test.xsd test.2.xml

I've done test on 2.9.2 and of course on reported version (2.7.6) (same results).
Comment 1 Marek Silewicz 2014-12-23 12:23:47 UTC
When i put tag <foo> at the end (after tag <country>) result is as follows:

<person id="441a5a57-9225-4021-9cc1-8ce30c43389f">
  <name>John Doe</name>
  <address>
    <line-1>300 BOYLSTON AVE E</line-1>
    <city>TUCSON</city>
    <state>AZ</state>
    <zip-code fake-attr="foo">85705</zip-code>
    <country fake-attr2="foo">US</country>
    <foo>BAR</foo>
  </address>
</person>
test.3.xml:8: element zip-code: Schemas validity error : Element 'zip-code', attribute 'fake-attr': The attribute 'fake-attr' is not allowed.
test.3.xml:9: element country: Schemas validity error : Element 'country', attribute 'fake-attr2': The attribute 'fake-attr2' is not allowed.
test.3.xml:10: element foo: Schemas validity error : Element 'foo': This element is not expected.
test.3.xml fails to validate

both required three validations problems were reported.
Comment 2 zhouzhongyuan 2019-08-13 08:06:26 UTC
This error caused by unsuited schema files. "zip-code" element contains attributes and text. It should belong Composite element and  cannot be verified by simple element schema .
Comment 3 GNOME Infrastructure Team 2021-07-05 13:21:04 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxml2/-/issues/

Thank you for your understanding and your help.