Start New Discussion within our Software Development Community

Not entirely sure what's happening. I've managed to narrow down the template where this error is occurring

<xsl:template match="Application/Comment">
    <xsl:copy>
        <xsl:choose>
            <xsl:when test="string($ImportXML/Application/Comment)">
                <xsl:apply-templates select="$ImportXML/Application/Comment/text()"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="."/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:copy>
</xsl:template>

$ImportXML/Application/Comment = "test". Essentially, I'm trying to update my document so that the XPath Application/Comment is now populated with "test". It is currently a blank element with no text or value but when I run the stylesheet over the xml, I am left with that error message

Can anyone help? Would be greatly appreciated.

By the way, I am using XSL version 1.0

Your issue lies in the <xsl:otherwise>.

You are selecting the current node Application/Comment with <xsl:apply-templates select="."/> and then applying templates against it, triggering an infinite loop as this simply calls the same template over and over, eventually running out of memory causing the stack overflow you are seeing.

Tested this within Visual Studio debugging the XSL as best I could with the data provided and was able to recreate the issue.

This question has already been answered. Start a new discussion instead.