I have the following XSL file which will be repeated many times (in my case 4 times):
In case the provided XSLT part is e.g. in an <xsl:for-each>
loop, you can use position()
to get an incremented value (the current position in the loop) and concat()
:
<span id="concat('spnCity', position())">
Update as suggested approach didn't work in the settings:
Two different kind of notations that should work are:
<span>
<xsl:attribute name="id" select="concat('spnCity', position())"/>
</span>
and
<span>
<xsl:attribute name="id">
<xsl:value-of select="concat('spnCity', position())"/>
</xsl:attribute>
</span>
The content can just be added after the attribute:
<span>
<xsl:attribute name="id">
<xsl:value-of select="concat('spnCity', position())"/>
</xsl:attribute>
<xsl:value-of select="Html/root/lcGroup/txtCity" />
</span>
Just created a Demo with both versions.