GNOME Bugzilla – Bug 669819
xmllint fails validating nil complextype xs:all
Last modified: 2021-07-05 13:22:06 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
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.