Subject:XSLT - Trapped in Recursive Template Loop Author:Brandon H. Date:01 Dec 2005 04:21 PM
I have an XSL stylesheet which is transforming XML into Excel. One section of the report using some complicated recursive looping to generate a 3 column tiling function.
The stylesheet uses two templates to achieve this tiling - code as follows.
<!--- Here is the template call from the main template -->
<xsl:apply-templates select="/OFFER/KIT-Children/KIT" />
.....
<!--- Here is the match template for KIT --->
<xsl:template match="KIT">
<xsl:call-template name="Kits">
<xsl:with-param name="cycle_count" select="1" />
</xsl:call-template>
</xsl:template>
I walk this transformation with my debugger and see that it fails the <xsl:if.../> logic test and exits the 'Kits' named template, but then the transform loops back to the:
Which calls the named 'Kits' template again with the reset 'cycle_count' parameter - this causes the transformation to get stuck in a never-ending recursive loop.
Subject:XSLT - Trapped in Recursive Template Loop Author:Minollo I. Date:01 Dec 2005 05:21 PM
Brandon,
from what you are describing I would expect the match="KIT" template to be executed as many times as many /OFFER/KIT-Children/KIT elements you have in your source document, because you are doing <xsl:apply-templates select="/OFFER/KIT-Children/KIT"/>.
But I wouldn't expect an infinite loop as long as the <xsl:if> logic is properly implemented. Have you verified if the match="KIT" template is being executed every time with the same context note? You can see the context node in the Stylus Studio Variables window.