Re: [xsl] xsl:import

Subject: Re: [xsl] xsl:import
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 23 Jul 2017 12:50:13 -0000
In XSLT 3.0 you can do this with static variables/parameters:

<xsl:param name="disk" static="yes" required="yes">

<xsl:import _href="{$disk}/path"/>

Note the underscore. This is referred to as a "shadow attribute" - it is
evaluated at preprocessing time (like use-when). The value of the static
parameter $disk must be available at compile time. In this example I've made
it required, but you can give it a default if you want, and make it optional.

It can't be done in 2.0 unless you implement your own preprocessor.

Michael Kay
Saxonica

> On 23 Jul 2017, at 13:03, Dave Pawson dave.pawson@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> AFAICT I can't use a variable inside an import?
>
> <xsl:import href="{$disk}/path"/>
>
> I'm running with all xsl files on a HDD (currently XXX)
> and know I'll change it to YYY in a year or so.
>
> Is there any way to use the above syntax?
> I.e. prefix the 'disk' to a given path?
>
> Relative paths are an option (but messy in my case)
>
> TiA
>
>
> --
> Dave Pawson
> XSLT XSL-FO FAQ.
> Docbook FAQ.
> http://www.dpawson.co.uk

Current Thread