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 385372 - xmllint only validates the last element in choice and produces warnings on "shared/choiced" fixed attributes
xmllint only validates the last element in choice and produces warnings on "s...
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xmlschema
2.6.x
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2006-12-13 08:26 UTC by linuxworld
Modified: 2021-07-05 13:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12



Description linuxworld 2006-12-13 08:26:49 UTC
Please describe the problem:
With the the xml file (xmllint.xml)
==================8<=================================================

<?xml version="1.0" encoding="utf8"?>
<pet>
        <animal name="dog" type="dangerous"/>
</pet>

==================8<=================================================
and its xsd schema (xmllint.xsd)
==================8<=================================================
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >

        <xs:element name="pet">
                <xs:complexType>
                        <xs:choice>
                                <xs:element name="animal" type="cat"/>
                                <xs:element name="animal" type="dog"/>
                                <xs:element name="animal" type="hamster"/>
                                <xs:element name="animal" type="lion"/>
                        </xs:choice>
                </xs:complexType>
        </xs:element>

        <xs:complexType name="cat">
                <xs:attribute name="name" use="required" fixed="cat"/>
                <xs:attribute name="type" use="optional" default="friendly"/>
        </xs:complexType>

        <xs:complexType name="hamster">
                <xs:attribute name="name"  use="required" fixed="hamster"/>
                <xs:attribute name="type"  use="optional" default="friendly"/>
        </xs:complexType>

        <xs:complexType name="dog">
                <xs:attribute name="name" use="required" fixed="dog"/>
                <xs:attribute name="type"  use="optional" default="friendly"/>
        </xs:complexType>

        <xs:complexType name="lion">
                <xs:attribute name="name" use="required" fixed="lion"/>
                <xs:attribute name="type"   use="optional"
default="dangerous"/>
        </xs:complexType>

</xs:schema>
==================8<=================================================
xmllint validation (2.6.17) failed and produces:
on line 3 element animal: Element 'animal', attribute 'name': The value 'dog'
does not match the fixed value constraint 'lion'.

but if we choose lion, it works. 

This simple example reveals that only the last pet in the choice is checked.


Steps to reproduce:
To prove this again, if we change fixed="lion" to default="lion" (forcing to
switch use to "optional") it works..and the funny part is...it works whatever
you put in name of pet of the xml file..dangerous validation huh?

Actual results:


Expected results:
I expect that :
1) it validates all the pets given (ie whose name is dog,cat,hamster or lion) not only lion. 
2) in case I provide lion with name as default attribute (dangerous workaround), the other fixed values are checked (not ignored)
3) Each fixed attribute value on each element in choice that does not validates should do not produce warnings if one of the other element in the choice validates.

Does this happen every time?


Other information:
Comment 1 GNOME Infrastructure Team 2021-07-05 13:27:23 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.