I am having trouble understanding the behavior of the following stylesheet.
I intended for the main template to build a node-list of <item> elements and
then process them using another template, but instead Saxon 6.5.2 is giving
me a stack overflow error. If I change the 'apply-templates' and
corresponding template to use a mode, it works as intended (outputs 'hello'
and 'goodbye').
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"
standalone="no"/>
<xsl:template match="/">
<xsl:variable name="item-elements">
<xsl:element name="item">hello</xsl:element>
<xsl:element name="item">goodbye</xsl:element>
</xsl:variable>
<xsl:apply-templates select="$item-elements"/>
</xsl:template>
<xsl:template match="item">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Why the infinite loop?
--
Roger L. Cauvin
roger(_at_)cauvin(_dot_)org