Re: [xslt] scope of variables
- From: <Nicholas_Liebmann McAfee com>
- To: <xslt gnome org>
- Subject: Re: [xslt] scope of variables
- Date: Fri, 27 Mar 2009 06:47:03 -0500
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
e.g
<xsl:variable name="x" select="'x'"/>
<func:function name="matchFunc">
<xsl:param name="arg"/>
<func:result select="$arg = $x"/>
</func:function>
<xsl:template match="x[matchFunc(@name)]">
<xsl:message>@name is <xsl:value-of select="$x"/></xsl:message>
</xsl:template>
<xsl:template match="x[not(matchFunc(@name))]">
<xsl:message>@name is NOT <xsl:value-of select="$x"/></xsl:message>
</xsl:template>
NOTE: You will need to set your stylesheet version to 1.1, and add the requisite namespace/extenstion declarations
Regards
Nick
-----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.
http://www.w3.org/TR/xslt#section-Defining-Template-Rules
It is an error for the value of the match attribute to contain a
VariableReference.
Mike
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt gnome org
http://mail.gnome.org/mailman/listinfo/xslt
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]