[xslt] apparent corruption of global variable value in a specific case


We seem to have discovered a strange bug in libxslt where the value of a global variable is being reported incorrectly as an empty string.

This occurs if you have a certain combination of global variables, template calls and functions returning result tree fragments.

Here is the output of the test case (just run it against itself), the libxslt version information, and the test case itself:

[pawlowski dev3 libxml]$ ./bin/xsltproc test-case.xsl test-case.xsl
assert 'success!' == ''

[pawlowski dev3 libxml]$ ./bin/xsltproc --version
Using libxml 20702, libxslt 10124 and libexslt 813
xsltproc was compiled against libxml 20702, libxslt 10124 and libexslt 813
libxslt 10124 was compiled against libxml 20702
libexslt 813 was compiled against libxml 20702

=== our test case ===

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
<xsl:output method="text" />

<!-- $func-value should have the value 'success!' but instead reports an empty string -->
<xsl:variable name="func-value" select="foo:get-value()" />
<xsl:variable name="dummy-value" select="$func-value" />
<xsl:variable name="template-value">
  <xsl:call-template name="get-dummy" />

<func:function name="foo:get-value">

<!-- use this func:result instead and $func-value will report the expected value
  <func:result select="'success!'" />

<xsl:template name="get-dummy">
  <xsl:value-of select="$dummy-value" />

<xsl:template match="/">
  <xsl:text>assert 'success!' == '</xsl:text>
  <xsl:value-of select="$func-value" />


=== end test case ===

It seems obscure, but in our very complex, several thousand line XSL transformations, this actually comes up pretty frequently and is frustrating to debug -- I hope you might be able to help us fix the problem.

Thanks for your help,

Peter Pawlowski

Senior Software Engineer
pawlowski vivisimo com

Vivisimo [Search Done Right]
1710 Murray Avenue
Pittsburgh, PA 15217 USA
tel: +1.412.422.2499 x116
fax: +1.412.422.2495
vivisimo.com      clusty.com

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