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 135864 - xml:base resolving relative to top element
xml:base resolving relative to top element
Status: VERIFIED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.5
Other Windows
: Normal normal
: ---
Assigned To: William M. Brack
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2004-03-01 19:22 UTC by Bob Stayton
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bob Stayton 2004-03-01 19:22:13 UTC
When processing nested XIncludes, the processor resolves each relative 
xml:base relative to the top level document. According to my reading of 
xml:base, a relative xml:base should resolve relative to its parent 
element.

Here are three short example files to illustrate the problem.
This is the top level document:

<?xml version="1.0" encoding="utf-8"?>
<book>
<xi:include href="modules/chapter1.xml" parse="xml"   
xmlns:xi="http://www.w3.org/2003/XInclude"/>
</book>

This is modules/chapter1.xml:

<?xml version="1.0" encoding="UTF-8"?>
<chapter>
<xi:include href="sections/section.xml" parse="xml" 
xmlns:xi="http://www.w3.org/2003/XInclude"/>
</chapter>

This is modules/sections/section.xml:

<?xml version="1.0" encoding="utf-8"?>
<section>
<para>
This is some text to see where I'm going.
</para>
</section>

When I process includetop.xml with xmllint --xinclude, I get:

<?xml version="1.0" encoding="utf-8"?>
<book>
<chapter xml:base="modules/chapter1.xml">
<section xml:base="modules/sections/section.xml">
<para>
This is some text to see where I'm going.
</para>
</section>
</chapter>
</book>


I would have expected the second xml:base to be "sections/section.xml" 
since the section element's parent has an xml:base that 
includes "modules".

I need to resolve this so that the DocBook XSL stylesheets can properly 
resolve the relative locations of graphics files within an element that 
has xml:base.  I thought it needed to merge the xml:base attributes for 
all of its ancestors, but the behavior of xmllint suggests it just needs 
to use the closest ancestor's xml:base.
Comment 1 William M. Brack 2004-05-28 14:55:43 UTC
According to my reading of the XInclude spec, your expectation is correct. I 
have coded a proposed fix, but I need to consult with Daniel before committing 
it.  In any event, it should be resolved before the next release.  Sorry for 
the rather lengthy time to get this bug fixed.

Bill
Comment 2 William M. Brack 2004-06-07 09:05:48 UTC
Well, that was a lengthy consultation :-).  The proposed fix grew into a new 
library routine to handle relative URI's, plus some additional enhancement to 
xinclude.c.  It certainly handles your test case:
bill@billsuper bug135864 $ ./xmllint --xinclude bug.xml
<?xml version="1.0" encoding="utf-8"?>
<book>
<chapter xml:base="modules/chapter1.xml">
<section xml:base="sections/section.xml">
<para>
This is some text to see where I'm going.
</para>
</section>
</chapter>
</book>

The fix has been committed to CVS (xinclude.c, uri.c, include/libxml/uri.h).  
I would appreciate it if you could exercise it as much as possible before the 
next release and report back any further problems.

Thanks for your patience, and my apologies for the time it has taken to 
resolve this.

Bill
Comment 3 Daniel Veillard 2004-07-06 09:06:48 UTC
This should be closed in libxml2-2.6.11,
                                                                                
  thanks,
                                                                                
Daniel