Re: [xslt] scope of variables



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.

On 27/03/2009, Frank Steinberg <steinberg ibr cs tu-bs de> wrote:
> Hi,
>
> I'm using libxml2/libxslt for a couple of years. When I recently moved
> some XSLT code from an old machine running libxslt 1.1.12 to a newer
> machine that is running 1.1.24, I found a problem with the scope of
> global variables. I could reduce the case to the following very short
> (meaningless) snippet:
>
> $ cat test.xsl
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform
> ">
>    <xsl:variable name="x">x</xsl:variable>
>    <xsl:template match="x[ name = $x]"/>
> </xsl:stylesheet>
>
> $ xsltproc test.xsl test.xsl
> XPath error : Undefined variable
> compilation error: file test.xsl line 4 element template
> Failed to compile predicate
>
> 1.1.12 does not lead to this error. From reading the specs I cannot
> see why the global variable $x is not defined within the Xpath
> expression of a template's "match" attribute.
>
> Does anybody have an explanation for this changed bahavior? Am I doing
> something wrong?
>
> Thanks,
>
>   -frank
>
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt gnome org
> http://mail.gnome.org/mailman/listinfo/xslt
>


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