You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Zeljko Rajic <Ze...@brokat.com> on 2000/11/22 10:54:32 UTC

bug with recursive template calls

Hi !

I'm new to this list and also a rookie with XML/XSL.
Currently I'm trying to create a XSL stylesheet which uses recursive template
calls. As it didn't work as I expected, I took an sample application from
Michael Kay's book "XSLT Programmer's Reference" and tried that one.

The sample XML and XSL files look like this:

<?xml version="1.0" encoding="UTF-8"?>
<numbers>12  34.5  18.2  -35</numbers>


And:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

<xsl:template name="total-numbers">
   <xsl:param name="list"/>
   <xsl:variable name="wlist" 
      select="concat(normalize-space($list), ' ')"/>
   <xsl:choose>
      <xsl:when test="$wlist!=' '">
         <xsl:variable name="first" 
            select="substring-before($wlist, ' ')"/>
         <xsl:variable name="rest" 
            select="substring-after($wlist, ' ')"/>
         <xsl:variable name="total">
            <xsl:call-template name="total-numbers">
               <xsl:with-param name="list" select="$rest"/>
            </xsl:call-template>
         </xsl:variable>
         <xsl:value-of select="number($first) + number($total)"/>
      </xsl:when>
      <xsl:otherwise>0</xsl:otherwise>
   </xsl:choose>
</xsl:template>

<xsl:template match="/">
   <xsl:call-template name="total-numbers">
      <xsl:with-param name="list" select="."/>
   </xsl:call-template>
</xsl:template>

</xsl:stylesheet>


The task of the XSL stylesheet is to add up the numbers listed within the
'numbers' element from the XML file.
I've tried this sample with both, Xalan 1.2.1 and Xalan 2.0 on WinNT using JDK
1.2.2 and both times the result was wrong (-1323) !!  :(

Afterwards I've tried the same sample with Saxon 5.5.1 and Xt from J. Clark.
Both of them produced the correct output (29,7).

Thus now I'm not sure if there is a bug in Xalan's "arithmetic" unit or if
Xalan's DTM has got problems with recursive template calls - or maybe a failure
at pattern matching ?!

So now I hope to find someone who could give me some more information about the
reason for the malfunction/bug when using Xalan.

Many thanks in advance!

-  Zeljko Rajic

Re: bug with recursive template calls

Posted by Zeljko Rajic <Ze...@brokat.com>.
Hmmm... that makes me wondering because I do not have any idea what I did wrong
- especially because the sample works fine with Saxon and Xt.  I tried that over
and over again!!!
Anybody got an assumption what I might have done wrong with Xalan?

This is how I called the sample:

java -classpath "C:\Xalan20\bin\xerces.jar;C:\Xalan20\bin\xalan.jar"
org.apache.xalan.xslt.Process -in  number-list.xml -xsl number-total.xsl -out
result.xml

Hope somebody can give me a tip !

-  Zeljko


Gary L Peskin wrote:
> 
> Zeljko Rajic wrote:
> > The task of the XSL stylesheet is to add up the numbers listed within the
> > 'numbers' element from the XML file.
> > I've tried this sample with both, Xalan 1.2.1 and Xalan 2.0 on WinNT using JDK
> > 1.2.2 and both times the result was wrong (-1323) !!  :(
> >
> > Afterwards I've tried the same sample with Saxon 5.5.1 and Xt from J. Clark.
> > Both of them produced the correct output (29,7).
> 
> I just tried this in both XalanJ 1.2.1 and the latest XalanJ2 and get
> the 29.7 both times.
> 
> Gary

Re: bug with recursive template calls

Posted by Gary L Peskin <ga...@firstech.com>.
Zeljko Rajic wrote:
> 
> Gary,
> 
> on what kind of machine did you try? I tested the sample on NT SP5, NT SP6 and
> Solaris 7. All with Sun's JDK 1.2.2_06 and with Xalan 2.0_D01 and Xalan 1.2.1 !
> The result is that the sample works fine on NT SP6 and Solaris, but does not
> work on NT SP5 !!  :(
> 
> I've attached the sample in the hope that somebody else could try out and give
> me a report if the sample works using Xalan on Windows NT with Servicepack 5 !

Zeljko --

I'm using Sun's JDK 1.1.8 and IBM's JDK 1.3 on NT SP 6a.  Sorry I don't
have access to an SP5 machine.

Gary

Re: bug with recursive template calls

Posted by Zeljko Rajic <Ze...@brokat.com>.
Gary,

on what kind of machine did you try? I tested the sample on NT SP5, NT SP6 and
Solaris 7. All with Sun's JDK 1.2.2_06 and with Xalan 2.0_D01 and Xalan 1.2.1 ! 
The result is that the sample works fine on NT SP6 and Solaris, but does not
work on NT SP5 !!  :(

I've attached the sample in the hope that somebody else could try out and give
me a report if the sample works using Xalan on Windows NT with Servicepack 5 !

Many thanks in advance for any support.

-  Zeljko


Gary L Peskin wrote:
> 
> Zeljko Rajic wrote:
> > The task of the XSL stylesheet is to add up the numbers listed within the
> > 'numbers' element from the XML file.
> > I've tried this sample with both, Xalan 1.2.1 and Xalan 2.0 on WinNT using JDK
> > 1.2.2 and both times the result was wrong (-1323) !!  :(
> >
> > Afterwards I've tried the same sample with Saxon 5.5.1 and Xt from J. Clark.
> > Both of them produced the correct output (29,7).
> 
> I just tried this in both XalanJ 1.2.1 and the latest XalanJ2 and get
> the 29.7 both times.
> 
> Gary

Re: bug with recursive template calls

Posted by Gary L Peskin <ga...@firstech.com>.
Zeljko Rajic wrote:
> The task of the XSL stylesheet is to add up the numbers listed within the
> 'numbers' element from the XML file.
> I've tried this sample with both, Xalan 1.2.1 and Xalan 2.0 on WinNT using JDK
> 1.2.2 and both times the result was wrong (-1323) !!  :(
> 
> Afterwards I've tried the same sample with Saxon 5.5.1 and Xt from J. Clark.
> Both of them produced the correct output (29,7).

I just tried this in both XalanJ 1.2.1 and the latest XalanJ2 and get
the 29.7 both times.

Gary