I’m using XSLT to pull some data from child nodes in an Umbraco (4.7) structure. That part is working fine, but I need to style each <li> item slightly different, so each one will be: <li id=x> where x is an integer between 1 and 15.
I’ve found a couple of methods for incrementing a counter value in XSLT, but I can’t tell why it’s not working as it should. Here’s the relevant source:
<ul>
<xsl:for-each select="$currentPage/Solutions/SolutionsItem[@isDoc]">
<xsl:variable name="count">
<xsl:number/>
</xsl:variable>
<li id="$count">
<a><xsl:value-of select="solutionsItemTitle" /></a>
</li>
</xsl:for-each>
</ul>
When I review the HTML’s source after running the XSLT, it just shows <li id=$count> rather than an integer. Can anyone suggest where to go from here?
You need an attribute value template
<li id="{$count}">...</li>to compute the attribute value from the XPath expression.