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 669819 - xmllint fails validating nil complextype xs:all
xmllint fails validating nil complextype xs:all
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xmlschema
2.7.8
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2012-02-10 16:57 UTC by Mina Naguib
Modified: 2021-07-05 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mina Naguib 2012-02-10 16:57:28 UTC
This bug is slightly similar to #358125

Given this valid XSD:

<?xml version="1.0" encoding="UTF-8"?>                                                                                                                                                 

<xs:schema                                                                                                                                                                             
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:example="http://example.com"
  targetNamespace="http://example.com"
  elementFormDefault="qualified"
  >

  <xs:complexType name="address">
    <xs:all>
      <xs:element name="country" type="xs:string"></xs:element>
      <xs:element name="state" type="xs:string"></xs:element>
      <xs:element name="city" type="xs:string"></xs:element>
    </xs:all>
  </xs:complexType>

  <xs:element name="person">
    <xs:complexType>
      <xs:all>
        <xs:element name="name" type="xs:string"></xs:element>
        <xs:element name="address" type="example:address" nillable="true"></xs:element>
      </xs:all>
    </xs:complexType>
  </xs:element>

</xs:schema>


and this valid document:

<?xml version="1.0" encoding="UTF-8"?>                                                                                                                                                 

<person
  xmlns="http://example.com"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  >
  <name>Bob</name>
  <address xsi:nil="true" />
</person>

Validation fails:
$ xmllint -schema person.xsd person.xml 
<?xml version="1.0" encoding="UTF-8"?>
<person xmlns="http://example.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <name>Bob</name>
  <address xsi:nil="true"/>
</person>
person.xml:8: element address: Schemas validity error : Element '{http://example.com}address': Missing child element(s). Expected is one of ( {http://example.com}country, {http://example.com}state, {http://example.com}city ).
person.xml fails to validate

It seems it insists on validating the innards of "address" even though it's specified as nil, and its definition in the schema allows it to be nil.

Through experimentation I've found two variations to the above that makes validation succeed, though logically undesirable on my end:

1. set minOccurs="0" to country/state/city in the schema
OR
2. Change the complexType definition from :sequence to :all


It seems the similar bug I mentioned (#358125) was only centered around xs:sequence, and this bug is around xs:all
Comment 1 GNOME Infrastructure Team 2021-07-05 13:22:06 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.