<xslTutorial creator="nicmila@idoox.com">
<index keywords='xsl:for-each xsl:if last() position()'/>
<description>xsl:if instruction enables conditional processing. <stylesheet id='id2'/> demonstrates a typical case of xsl:for-each usage, adding a text between individual entries. Very often you do not want to add text after the last element. xsl-if construct comes handy here. (<stylesheet id='id3'/>) </description>
<xmlSource id="id1">
<list>
<entry name="A"/>
<entry name="B"/>
<entry name="C"/>
<entry name="D"/>
</list>
</xmlSource>
<attValues>
<value match="">
</value>
</attValues>
<xslStylesheet id="id2">
<xsl:template match="list">
<xsl:for-each select="entry">
<xsl:value-of select="@name"/>
<xsl:text>, </xsl:text>
</xsl:for-each>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id3">
<xsl:template match="list">
<xsl:for-each select="entry">
<xsl:value-of select="@name"/>
<xsl:if test="not (position()=last())">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xslStylesheet>
</xslTutorial>