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 <abel.online@xxxxxxxxx>
Date: Mon, 09 Oct 2006 19:59:38 +0200
Michael Kay wrote:
You either
need to do the call on document() in the importing module; or you need to
make the base URI of the importing module accessible to the imported module
for example by declaring a global variable

<xsl:variable name="importing-base-uri" select="base-uri()"/>

in the importing module.

Thanks Michael.
This tip, combined with all the details provided by David and others, I thought of the following solution as a perfect best of breed, but couldn't get it to work:
- in the imported stylesheet, add a parameter 'importing-base-uri', required = yes.
- in the importing stylesheet, add the same parameter, but now with a value, overriding the required-attribute in the imported stylesheet.


The purpose was, using this construct, to raise an error when a user-defined stylesheet (it is part of a bigger concept) does not add the 'importing-base-uri' in his stylesheet, without requiring the processor to add the parameter as well. Alas, this does not work. I found out that (http://www.w3.org/TR/xslt20/#global-variables):

"If a stylesheet contains more than one binding for a global variable of a particular name, then the binding with the highest import precedence is used."

This seems to only apply to the binding, not to the other attributes of a parameter. But this import precedence does apply, when going from required=no to required=yes (???). Yes, really, like this:

IMPORTED: <xsl:param name="resource-location-url" select="'../'" />

IMPORTING: <xsl:param name="resource-location-url" required="yes" />

This works, making the resulting parameter, after import precedence, required. But I want it the other way around (making a required param non-required), which does not work, and leaves the resulting parameter as required (instead of being overridden by the importing param, like above).

Is this strange, or is it just me, or do I need new glasses? :D

I guess I have to resort to using the non-required variant.

-- Abel Braaksma
  http://www.nuntia.com

Current Thread