Re: [xsl] xml:base, resolve-uri and imported xslt files: how to get the importing base url from imported xslt

Subject: Re: [xsl] xml:base, resolve-uri and imported xslt files: how to get the importing base url from imported xslt
From: Abel Braaksma <>
Date: Mon, 09 Oct 2006 19:32:28 +0200
David Carlisle wrote:

the variable pathToConfig holds a string not a uri so it is not subject to any uri resolution while being passed around -as a string- If you then use it in a place where a URI is expected (eg the argument to doc()) then (in any particular instance) URI resolution will be just as if a string constant had been used at that point, the string valued variable doesn't hold any information about _where_ it was defined.

Does that mean that when I change is to type of 'xs:anyUri', it will be interpreted differently?

which is effectively similar to my suggestion of calling doc() in the importing stylesheet rather than the imported one, both have the effect of doing the resolution at that point.

Yep, now I see that too

No the base URI of each stylesheet module is (unless overrideen with
xml:base) the URI used to retrieve that module.

In one way that is contrary to what I understand from the specification, yet it is totally understandable from the context of making stand-alone templates that should be used for inclusion: how can you otherwise rely on the relativity of the paths you specify for your imports or document() function if they change once your stylesheet is included elsewhere...

Still it is confusing. What I got, so far, from self experience and borrowed from more experienced people, is the following incomplete list about W3 standards regarding this and related:

- xsl:import changes the base-href for the imported document to that of itself

- xsl:include changes the base-href for the included document to that of itself

- @import (css) changes the base-href, EXCEPT when you use a filter, which defaults to the including HTML file as base. This is MS specific. Note that inline css uses the base href from the parent element, and thus the html page, same as with xslt.

- script src (html)
js files included will inherit the base href from the main html page (with XMLHttpRequest, for instance, or when you create any HTML DOM element)

- xslt created via DOM
looses the base-href completely (I have yet to find out what happens here)

So, there appears to be a clear tendency here, even though it is not yet all up to the same. The href of the document itself will be the base href. ;)

You don't have to navigate the xsl:import tree.

I understand that now.

Current Thread