how can I refer to the current node matched by a template, within a for-each
loop.
<xsl:template match="product[@category='foo']">
<count>
<xsl:for-each select="preceding::product">
<current>
<xsl:value-of select="count(current()/preceding::product)"/>
</current>
<context>
<xsl:value-of select="count(./preceding::product)"/>
</context>
</xsl:for-each>
</count>
</xsl:template>
Both count()
functions return the same results with .
as well as current()
.
Is there a way to refer to the matched node of the template, in order to count all the preceding nodes of it, so that the result of the count()
function inside <current/>
is the same for every for-each
step.
Thanks!