Hi,
I have an XSLT script which I would like to number things sequentially each time I call a template. So a very abbreviated version of it looks a bit like:
<xsl:call-template name="insertHeader" />
<xsl:for-each ...>
<xsl:call-template name="insertHeader" />
...
</xsl:for-each>
<xsl:call-template name="insertHeader" />
<xsl:template name="insertHeader>
This is item number <xsl:value-of select="$numberOfInvocations />
</xsl:template>
So obviously that $numberOfInvocations thing doesn't work, and in XSLT you can't increment a global counter variable which would seem like an obvious approach in a procedural language. I would like it to print out 1 the first time that template is called, 2 the second, etc. How should I go about doing this? Is this even remotely possible in XSLT?
Thanks :)
Edit: So there have been a couple of comments that this isn't clearly defined enough. What I want to do is label a series of tables in the (HTML) output. The most obvious way I see of doing this is to call a function (you can probably tell that I am not an XSLT wizard here) that will automatically increment the number each time. I think the reason this seems so hard is because it's the XSLT itself that defines where these tables appear rather than the input.
This extra info may not be of that much use though since Dimitre's answer makes it sound rather like this is never going to work. Thanks anyway :)