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 115421 - xmllint fails validation with RELAX NG schema which has nested 'interleave' elements.
xmllint fails validation with RELAX NG schema which has nested 'interleave' e...
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: relaxng
2.5.7
Other Linux
: Normal major
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2003-06-18 04:28 UTC by Ryosuke Nanba
Modified: 2021-07-05 13:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ryosuke Nanba 2003-06-18 04:28:54 UTC
libxml 2.5.7's xmllint fails to validate document below:

<root>
  <A><a/><b/><c/><d/></A>
  <A><a/><b/><d/><c/></A>
  <A><a/><c/><b/><d/></A><!-- libxml2 fails to validate this -->
  <A><a/><c/><d/><b/></A>
  <A><a/><d/><b/><c/></A><!-- libxml2 fails to validate this -->
  <A><a/><d/><c/><b/></A>
  <A><b/><a/><c/><d/></A>
  <A><b/><a/><d/><c/></A>
  <A><b/><c/><a/><d/></A><!-- libxml2 fails to validate this -->
  <A><b/><c/><d/><a/></A>
  <A><b/><d/><a/><c/></A><!-- libxml2 fails to validate this -->
  <A><b/><d/><c/><a/></A>
  <A><c/><a/><b/><d/></A>
  <A><c/><a/><d/><b/></A>
  <A><c/><b/><a/><d/></A>
  <A><c/><b/><d/><a/></A>
  <A><c/><d/><a/><b/></A>
  <A><c/><d/><b/><a/></A>
  <A><d/><a/><b/><c/></A>
  <A><d/><a/><c/><b/></A>
  <A><d/><b/><a/><c/></A>
  <A><d/><b/><c/><a/></A>
  <A><d/><c/><a/><b/></A>
  <A><d/><c/><b/><a/></A>
</root>

with RELAX NG schema below:

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <ref name="root"/>
  </start>

  <define name="root">
    <element name="root">
     <zeroOrMore>
        <element name="A">
          <interleave>
	    <interleave>
	      <ref name="a"/>
	      <ref name="b"/>
	    </interleave>
	    <interleave>
	      <ref name="c"/>
	      <ref name="d"/>
	    </interleave>
	  </interleave>
        </element>
      </zeroOrMore>
    </element>
  </define>

  <define name="a">
    <element name="a"><empty/></element>
  </define>
  <define name="b">
    <element name="b"><empty/></element>
  </define>
  <define name="c">
    <element name="c"><empty/></element>
  </define>
  <define name="d">
    <element name="d"><empty/></element>
  </define>

</grammar>

nested 'interleave' element such as

  <interleave>
    <interleave>
      <ref name="a"/>
      <ref name="b"/>
    </interleave>
    <interleave>
      <ref name="c"/>
      <ref name="d"/>
    </interleave>
  </interleave>

is equivalent to flattened form such as

  <interleave>
    <ref name="a"/>
    <ref name="b"/>
    <ref name="c"/>
    <ref name="d"/>
  </interleave>

but, xmllint behave defferently.
Comment 1 Daniel Veillard 2003-07-05 22:04:53 UTC
Yeah the only problems I'm aware of with the Relax-NG code is
related to the exploration of all cases when processing 
interleaves. Your cascading triggers the limitation.

Daniel
Comment 2 Ryosuke Nanba 2005-05-21 09:09:10 UTC
I confirmed that libxml2-2.6.16 is not fixed yet...
Comment 3 John Mairs 2006-04-26 21:11:46 UTC
Just wondering the status on this bug.  I'm running into the same problem.

I have a list of preferences that are being serialized out in XML.  Each concrete preference is an object in a vector.

Right now I can only interleave the inner elements 

element sequence {
  element seq-element {
     (element autoSaveFlag
      ...
      }&
      element autoSaveMinutes
      ...
      })
  },
  element seq-element {
      (element showNameOption
       ...
      )&
  }

I sure would like to be able to restore the individual sequence elements in an interleaved order.
Comment 4 linuxworld 2006-12-11 16:45:57 UTC
I would like to share an experience here. Maybe it is relevant to the similar problem of interleave which can be repoduced in xml schema with a xs:choice structure. 

I use here the lastest xmllint 2.6.27 for the test and ran it under linux to validate the xml file (xmllint.xml)
==================8<=================================================

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

==================8<=================================================
with 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<=================================================

the validation 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.
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?

Comment 5 Daniel Veillard 2006-12-11 18:21:24 UTC
comment #4 is completely unrelated to this bug, I am positive about this,
the RNG And XSD don't share any code for this.
If you want any processing on it open another bug

Daniel
Comment 6 GNOME Infrastructure Team 2021-07-05 13:27:32 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.