You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Morten Primdahl <mo...@it-c.dk> on 2002/02/06 19:07:16 UTC

Limit on call-template stack?

I'm experiencing very strange behaviour from Xalan-J-2.2.14
(feature request: java org.apache.xalan.xslt.Process -VERSION)

1. Minor issue, <xsl:when test="$a < $b"> doesn't parse,
   while <xsl:when test="$b > $a"> works. I guess this
   is a bug?

2. When a call-template nests/recurses more than 1362 (!?)
   times, I get an ArrayIndexOutOfBoundsException

Consider the following XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<newsrcs>
<newsrc user="morten">
<group id="morten.test">
<read>
<number>398</number>
<number>55</number>
<range><low>0</low><high>1363</high></range>
</read>
</group>
</newsrc>
</newsrcs>

And apply the following stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output encoding="iso-8859-1"/>

<xsl:template match="newsrcs">
<xsl:apply-templates select="newsrc"/>
</xsl:template>

<xsl:template match="newsrc">
<xsl:apply-templates select="group"><xsl:with-param
name="uid"><xsl:value-of
select="@user"/></xsl:with-param></xsl:apply-templates>
</xsl:template>

<xsl:template match="group"><xsl:param name="uid"/>
<xsl:apply-templates select="read"><xsl:with-param
name="uid"><xsl:value-of select="$uid"/></xsl:with-param><xsl:with-param
name="gid"><xsl:value-of
select="translate(@id,'.','_')"/></xsl:with-param></xsl:apply-templates>
</xsl:template>

<xsl:template match="read"><xsl:param name="uid"/><xsl:param name="gid"/>
<xsl:apply-templates><xsl:with-param name="gid"
select="$gid"/><xsl:with-param name="uid"
select="$uid"/></xsl:apply-templates>
</xsl:template>

<xsl:template match="number"><xsl:param name="uid"/><xsl:param
name="gid"/>
<xsl:value-of select="."/>,<xsl:value-of select="$gid"/>,<xsl:value-of
select="$uid"/>
</xsl:template>

<xsl:template match="range"><xsl:param name="uid"/><xsl:param name="gid"/>
<xsl:call-template name="rangeExpand"><xsl:with-param name="gid"
select="$gid"/><xsl:with-param name="uid" select="$uid"/><xsl:with-param
name="low" select="low"/><xsl:with-param name="high"
select="high"/></xsl:call-template>
</xsl:template>

<xsl:template name="rangeExpand"><xsl:param name="uid"/><xsl:param
name="gid"/><xsl:param name="low"/><xsl:param name="high"/>
<xsl:choose>
  <xsl:when test="$high > $low">
    RANGE <xsl:value-of select="$low"/>,<xsl:value-of
select="$gid"/>,<xsl:value-of select="$uid"/><xsl:text></xsl:text>
    <xsl:call-template name="rangeExpand"><xsl:with-param name="gid"
select="$gid"/><xsl:with-param name="uid" select="$uid"/><xsl:with-param
name="low" select="$low+1"/><xsl:with-param name="high"
select="$high"/></xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="$high"/>,<xsl:value-of
select="$gid"/>,<xsl:value-of select="$uid"/>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

The spooky part is that if the <high>1363</high> gets set
to <high>1362</high>, the exception does not get thrown.
Hardcoded max array size?

Morten