[xslt] scope of variables



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



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