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 385796 - The content model is not determinist for complextypes with sequence in choice for XSD schemas
The content model is not determinist for complextypes with sequence in choice...
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xmlschema
2.6.x
Other All
: Normal minor
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-14 10:37 UTC by linuxworld
Modified: 2021-07-05 13:23 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12



Description linuxworld 2006-12-14 10:37:42 UTC
Please describe the problem:
Here are two packs XMLLINT1 and XMLLINT2, I use for the tests.
For each pack , is associated two xsd files marked with a and b. 
These two letters correspond to a version and have a particular meaning:
	a: choice is inside the root element
	b: choice is deported into an external complexType to produce a sort of "polymorphism" (avoiding to repeat 
	the element name)
Those 2 xsd serve for validation of the xml file that has the name of the pack.

========== PACK XMLLINT1 ==============================
xmllint1.xml:
---------------8<----------------------------------
<?xml version="1.0" encoding="utf8"?>
<pet>
	<animal>
		<type>dog</type>
	</animal>
</pet>
---------------8<----------------------------------
xmllint1a.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:choice>
		</xs:complexType>
	</xs:element>
	
	<xs:complexType name="cat">
		<xs:sequence>
			<xs:element name="type" default="cat"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="hamster">
		<xs:sequence>
			<xs:element name="type" default="hamster"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="dog">
		<xs:sequence>
			<xs:element name="type" default="dog"/>
		</xs:sequence>
	</xs:complexType>
	
</xs:schema>
---------------8<----------------------------------
xmllint1b.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="animal"/>
			</xs:choice>
		</xs:complexType>
	</xs:element>
	
	<xs:complexType name="animal">
		<xs:choice>
			<xs:element name="type" default="cat"/>
			<xs:element name="type" default="hamster"/>
			<xs:element name="type" default="dog"/>
		</xs:choice>
	</xs:complexType>
	
</xs:schema>
---------------8<----------------------------------
========================================================
============ PACK XMLLINT2 ==============================
xmllint2.xml:
---------------8<----------------------------------
<?xml version="1.0" encoding="utf8"?>
<pet>
	<animal>
		<type>dog</type>
		<name>charlie</name>
	</animal>
</pet>
---------------8<----------------------------------
xmllint2a.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:choice>
		</xs:complexType>
	</xs:element>
	
	<xs:complexType name="cat">
		<xs:sequence>
			<xs:element name="type" default="cat"/>
			<xs:element name="name"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="hamster">
		<xs:sequence>
			<xs:element name="type" default="hamster"/>
			<xs:element name="name"/>
		</xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="dog">
		<xs:sequence>
			<xs:element name="type" default="dog"/>
			<xs:element name="name"/>
		</xs:sequence>
	</xs:complexType>
	
</xs:schema>
---------------8<----------------------------------
xmllint1b.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="animal"/>
			</xs:choice>
		</xs:complexType>
	</xs:element>
	
	<xs:complexType name="animal">
		<xs:choice>
			<xs:sequence>
				<xs:element name="type" default="cat"/>
				<xs:element name="name"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="type" default="hamster"/>
				<xs:element name="name"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="type" default="dog"/>
				<xs:element name="name"/>
			</xs:sequence>
		</xs:choice>
	</xs:complexType>
	
</xs:schema>
---------------8<----------------------------------
==========================================================

Steps to reproduce:
Lets validate the xml file with the two provided xsd files of the pack 

Actual results:
-xmllint1a.xsd and xmllint1a.xsd validates xmllint1.xml
-xmllint2a.xsd validates xmllint2.xml
-xmllint2a.xsd fails validating xmllint2.xml:
Line 11 :  element complexType: Schemas complex type 'animal': The content model is not determinist. 

Expected results:
xmllint2b.xsd should validate xmllint2.xml too. 

Does this happen every time?


Other information:
I put the XMLLINT1 pack to demonstrate that the type grouping with one element it works fine. I wanted here to hilight the fact that it is possible to remove the determinism choice problem by splitting the Complextype into multiple parts like in xmllint2a. This is obviously a good workaround but size of the xsd will suffer from it.
Comment 1 Daniel Veillard 2006-12-14 11:36:54 UTC
A few point before you start going any further:
 - All of them look non-deterministic to me, and should probably be rejected
 - The person doing XSD support in libxml2 lost his job
 - libxml2 XSD result should be triple checked with at least 2 others validators
 - xmlschema-dev@w3.org is the place to ask whether something is valid or not,
   sometimes there is even an unambiguous answer
 - XSD (schemas part) semantic is not always defined, if you're really serious
   about validating use Relax-NG

Daniel

Comment 2 GNOME Infrastructure Team 2021-07-05 13:23:08 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.