After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 381319 - parameter variable of EXSLT-function not found
parameter variable of EXSLT-function not found
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-01 16:17 UTC by Martin Gieseking
Modified: 2006-12-11 23:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Martin Gieseking 2006-12-01 16:17:04 UTC
The attached sample files cause xsltproc (libxslt 1.1.18 and 1.1.19) to report the following error message although the "missing" parameter has been declared:

  runtime error: file test.xsl line 10 element variable
  Variable 'table' has not been declared.
  xmlXPathCompiledEval: evaluation failed
  runtime error: file test.xsl line 15 element param
  Failed to evaluate the expression of variable 'tr'.

This behavior was introduced with libxslt 1.1.18.

---

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common"
  xmlns:func="http://exslt.org/functions"
  xmlns:math="http://exslt.org/math"
  xmlns:mg="mg"
  extension-element-prefixes="exsl func">
	
  <xsl:template match="table">		
    <xsl:variable name="cols" select="mg:function(.)"/>		
  </xsl:template>	
	
  <func:function name="mg:function">
    <xsl:param name="table"/>
    <xsl:param name="tr" select="$table/tr[1]"/>		
    <func:result select="0"/>
  </func:function>	
</xsl:stylesheet>


<?xml version="1.0" encoding="UTF-8"?>
<root>
  <table>
    <tr>
      <td align="center">a</td>			
    </tr>
  </table>
</root>
Comment 1 William M. Brack 2006-12-09 23:23:55 UTC
Although this looked like a simple problem, it turned out to be a bit difficult (for me).  I have changed the logic of the module handling exslt:function, as well as a couple of other related spots, and I think it should now be ok.  Please try the current CVS with your original stylesheet and re-open the bug if there is any further problem.  I also added a slightly-modified version of your test case to the libxslt regression tests so that the situation will be tested and verified with any future releases.

Thanks for the report, and for your patience.
Comment 2 Martin Gieseking 2006-12-11 12:44:49 UTC
Thanks for your bugfix. Unfortunately, it seems there's still a problem with EXSLT function parameters, especially in conjunction with recursion.
When using the current CVS version the following stylesheet produces a wrong result. mg:recurse(5,1) should return 15 but I get 6.
Maybe a bug in the parameter stack management?


<xsl:stylesheet version="1.0" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:func="http://exslt.org/functions"   
   xmlns:mg="mg"
   extension-element-prefixes="func">

   <xsl:template match="text">      
      <xsl:value-of select="mg:recurse(5, 1)"/>
   </xsl:template>
      
   <func:function name="mg:recurse">
      <xsl:param name="a"/>
      <xsl:param name="b"/>
      <xsl:choose>
         <xsl:when test="$a > 0">            
            <func:result select="$a+mg:recurse($a - $b, $b)"/>
         </xsl:when>
         <xsl:otherwise>
            <func:result select="0"/>
         </xsl:otherwise>
      </xsl:choose>     
   </func:function>
</xsl:stylesheet>
Comment 3 Martin Gieseking 2006-12-11 12:49:33 UTC
Here is a more complete test case with sample xml file:

<xsl:stylesheet version="1.0" 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns:func="http://exslt.org/functions"   
   xmlns:mg="mg"
   extension-element-prefixes="func">

   <xsl:template match="root">
      <xsl:value-of select="mg:recurse(a, b)"/>
   </xsl:template>

   <func:function name="mg:recurse">
      <xsl:param name="a"/>
      <xsl:param name="b"/>
      <xsl:choose>
         <xsl:when test="$a > 0">            
            <func:result select="$a+mg:recurse($a - $b, $b)"/>
         </xsl:when>
         <xsl:otherwise>
            <func:result select="0"/>
         </xsl:otherwise>
      </xsl:choose>     
   </func:function>
</xsl:stylesheet>


<?xml version="1.0"?>
<root>
   <a>5</a>
   <b>1</b>
</root>
Comment 4 William M. Brack 2006-12-11 23:00:06 UTC
Yes, you are correct, there was an additional problem which wasn't revealed by the previous tests. I have enhanced the applicable code (libexslt/functions.c), and also added this test to the regression test suite.  Fixed code is in CVS.

Thanks for the report.