GNOME Bugzilla – Bug 324164
RelaxNG: "Extra element XXX in interleave"
Last modified: 2021-07-05 13:26:27 UTC
Please describe the problem: xmllint refuses as invalid some XML files described by a RelaxNG schema when this schema includes interleave. Steps to reproduce: Here is a simplified version of the original problem, which still demonstrates the bug. The schema: <?xml version="1.0" encoding="UTF-8"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <start> <ref name="content"/> </start> <define name="content"> <element name="content"> <mixed> <oneOrMore> <element name="para"> <interleave> <zeroOrMore> <ref name="inlines"/> </zeroOrMore> <zeroOrMore> <ref name="code"/> </zeroOrMore> </interleave> </element> </oneOrMore> </mixed> </element> </define> <define name="inlines"> <interleave> <zeroOrMore> <ref name="link"/> </zeroOrMore> <zeroOrMore> <ref name="emphasis"/> </zeroOrMore> <zeroOrMore> <text/> </zeroOrMore> </interleave> </define> <define name="code"> <element name="code"> <text/> </element> </define> <define name="emphasis"> <element name="emphasis"> <text/> </element> </define> <define name="link"> <element name="link"> <text/> </element> </define> </grammar> The test file: <content> <para>text <code>foo</code> text again <code>bar</code> </para> </content> Another test file which is accepted (because it only has one <code> element): <content> <para>text <code>foo</code> text <emphasis>again</emphasis> </para> <para>Another para</para> </content> The command-line to show the bug: xmllint --noout --relaxng schema.rng test.xml Actual results: test.xml:2: element para: Relax-NG validity error : Expecting an element got text Relax-NG validity error : Extra element text in interleave test.xml:2: element para: Relax-NG validity error : Element para failed to validate content test.xml fails to validate Expected results: A message "text.xml validates" Does this happen every time? Yes Other information: The jing validator or the nxml-mode editor have no problem so I believe this is a bug in libxml2.
yes doing interleave of interleave is likely to trigger a known bug in libxml2 RNG code. Daniel
rnv (http://ftp.davidashen.net/PreTI/RNV/) works fine too, so I agree this is a real bug in libxml2.
Sorry to revive this old thing, but I seem to face a similar issue on 2.6.31. As long as the xml file is valid, everything works ok, so in this regard the bug seems gone. But the bug reappears as soon as the xml is invalid, giving the user a completely bogus error message.
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.