Re: [xslt] scope of variables

I'm not sure if it is legal XSLT, nor whether it works in newer versions of libxslt, but to solve this problem, I use the EXSLT function extension

<xsl:variable name="x" select="'x'"/>

<func:function name="matchFunc">
   <xsl:param name="arg"/>

    <func:result select="$arg = $x"/>


<xsl:template match="x[matchFunc(@name)]">
<xsl:message>@name is <xsl:value-of select="$x"/></xsl:message>

<xsl:template match="x[not(matchFunc(@name))]">
<xsl:message>@name is NOT <xsl:value-of select="$x"/></xsl:message>

NOTE: You will need to set your stylesheet version to 1.1, and add the requisite namespace/extenstion declarations



-----Original Message-----
From: xslt-bounces gnome org [mailto:xslt-bounces gnome org] On Behalf Of Mike Hommey
Sent: 27 March 2009 10:36
To: The Gnome XSLT library mailing-list
Subject: Re: [xslt] scope of variables

On Fri, Mar 27, 2009 at 11:27:16AM +0100, Viktor Štujber <theultramage gmail com> wrote:
> The only thing that comes to mind is xslt's restriction that template
> matching rules must be static (couldn't find the place in the xslt
> spec though). If that's true, then usage of a variable ($x) is not
> allowed, even though in your example it's actually a constant. Perhaps
> libxslt changed its logic to be more strict in this regard...
> This is just a guess though. In your example, replacing the variable
> with a literal 'x' worked, and this is actually how one xslt script of
> mine works.
It is an error for the value of the match attribute to contain a

xslt mailing list, project page
xslt gnome org

McAfee International Limited is registered in England and Wales with its registered address at 100 New Bridge Street, London, Company No. 02825890

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]