Hello all.
I know that variables in xsl are immutable and cannot change but i need to work out a way to increment a variable which is then added on as a value to a tag.
As a solution ive read that recursive calls to a template achieve the same goal as incrementing a variable but i am new to xsl and am unsure how to proceed.
The scenario is as follows:
I have an example xml file of the following format :
Code:
<section>
<field id ="date1">
<datefield>
</field>
<field id ="date2">
<datefield>
</field>
<field id ="Name">
<textfield>
</field>
<field id ="Num1">
<numberfield>
</field>.....
</section>
I now need to loop through all fields and if they are a numberfield or datefield add a new element containing a count of the number of occurrences. eg
Code:
<xsl:for-each select="numberfield>
<countValue>
<xsl:attribute name="count"> ??incremental value here </xsl:attribute>
</xsl:for-each>
<xsl:for-each select="datefield>
<countValue>
<xsl:attribute name="count"> ??incremental value here </xsl:attribute>
</xsl:for-each>
This would theoretically give me the elements
date1 with a countValue of 1
date2 with a countValue of 2
num1 with a countValue of 3
Is this possible?
Many thanks for your anticipated assistance - i hope i have provided enough information to explain the problem.
Will