Subject: RE: Callstack overflow error !! It is not inifinte recusive loop ??
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 18 Sep 2003 20:18:16 +0100
|
Your recursive template is tail-recursive (the last thing it does is to
call itself) so a processor that does tail-call optimization should not
blow the stack. Try Saxon or jd.xslt.
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Dipesh Khakhkhar
> Sent: 18 September 2003 16:28
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Callstack overflow error !! It is not inifinte
> recusive loop ??
> Importance: High
>
>
> Hi,
>
> I am getting Callstack overflow error when a template is
> called recursively.
>
> I am finding unique attribute names for some node which is
> repeating itself
> many times say 100 or more than that. This node is having 11
> attributes. So
> first i am getting attribute names like this
>
> xsl:variable name="ResColNames"
> select="/Root/FirstNode/SecondNode/@*"/>
>
> So there are 100 or more SecondNode in the xml input document
> and each node is
> having 10 or more attributes.
>
> Then I am calling a recusive template to get the unique
> attribute names.
>
> <xsl:variable name="uniqueColumnNamesRes">
> <xsl:call-template
> name="findUniqueNamesForNodesWithAtt">
> <xsl:with-param name="names"
> select="$ResColNames"/>
> <xsl:with-param name="uniqueNames"/>
> <xsl:with-param name="i">0</xsl:with-param>
> </xsl:call-template>
> </xsl:variable>
>
> The following is the template which is called.
>
> <!-- This is to find unique Column Names for nodes with
> attributes as
> columns-->
> <xsl:template name="findUniqueNamesForNodesWithAtt">
> <xsl:param name="names"/>
> <xsl:param name="uniqueNames"/>
> <xsl:param name="i"/>
> <xsl:choose>
> <xsl:when test="$i <= count($names)">
> <xsl:variable name="newUniqueName">
> <xsl:choose>
> <xsl:when test="contains($uniqueNames, name($names[$i]))">
> <xsl:value-of select="$uniqueNames"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of
> select="concat($uniqueNames,'`',name($names[$i]))"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
> <xsl:call-template name="findUniqueNamesForNodesWithAtt">
> <xsl:with-param name="names" select="$names"/>
> <xsl:with-param name="uniqueNames" select="$newUniqueName"/>
> <xsl:with-param name="i" select="$i + 1"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="concat($uniqueNames,'`')"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
>
> The same template when called with the same input file is
> running without any
> error producing expected output. I am not able to figure out
> why this is
> executing properly.
>
> But when the same template is called for the same input file
> from different
> xsl file with same parameters it is giving stack overflow error.
>
> The iterating variable is reaching 248 and then it is giving
> error. Can
> someone please tell me what can be possible reasons? Is this
> a memory problem
> ? Or am I taking round about way which can be done in some
> simple way i.e. to
> find unique attribute names for some node. Or i should just
> hardcode the
> maximum possible attribute names i.e. required and implied
> from the dtd.
>
> The recursion is not going infinite I am comparing the
> variable with the count
> of one node-set variable having 829 nodes.
>
> Eagerly waiting for reply.
>
> Regards,
> Dipesh
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|