You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/02/12 12:52:23 UTC

DO NOT REPLY [Bug 16990] New: - Nested EXSLT functions generate error

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16990>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16990

Nested EXSLT functions generate error

           Summary: Nested EXSLT functions generate error
           Product: XalanJ2
           Version: 2.4
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: org.apache.xalan.lib
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: olaf_mueller@gmx.de


The bug appears when several EXSLT functions (func:function) are defined in a
template and one function makes a call to another function to include the return
value of that function into the calculation. In this case, Xalan generates the
following error message:

(Location of error unknown)XSLT Error
(javax.xml.transform.TransformerException):
javax.xml.transform.TransformerException:
An EXSLT function cannot set more than one result!

Probably, there have to be several objects holding the results of each function
call as long as the whole call stack is not completely processed.

I used Xalan-J version 2.4.1 in conjunction with the Xerces 2.2.0 that was in
the Xalan-J binary distribution. The exception occurred while testing the
transformation by calling Xalan on the command line, using the
org.apache.xalan.xslt.Process class.

Following is a XSL stylesheet to demonstrate the described behavior. You can use
any XML source document to reproduce the error, since no specific element of the
source document is addressed.

<code>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:func="http://exslt.org/functions"
  xmlns:my="blabla">
  
  <!-- This is just a dummy function. -->
  <func:function name="my:firstfunction">
    <xsl:param name="arg1" select="0"/>
    <func:result select="$arg1 + 1"/>
  </func:function>
  
  <!-- When this function is called, it generates output without error. -->
  <func:function name="my:secondfunction">
    <xsl:param name="arg" select="0"/>
    <func:result select="my:firstfunction($arg) + 2"/>
  </func:function>
  
  <!-- When this function is called, it generates the following error: -->
  <!-- javax.xml.transform.TransformerException:                       -->
  <!-- An EXSLT function cannot set more than one result!              -->
  <func:function name="my:thirdfunction">
    <xsl:param name="arg" select="0"/>
    <xsl:variable name="result" select="my:firstfunction($arg) + 2"/>
    <func:result select="$result"/>
  </func:function>
  
  <!-- The template. -->
  <xsl:template match="/">
    <!-- Comment out one of the next lines, run Xalan and see what happens. -->
    This function works: <xsl:value-of select="my:secondfunction(3)"/>
    That function fails: <xsl:value-of select="my:thirdfunction(3)"/>
  </xsl:template>
</xsl:stylesheet>

</code>