`<tr id='item-<xsl:value-of select="$item.count" />'>` : How to do it correctly?

30 Views Asked by At

XSL is not my daily job, but I'm trying to assign ascending IDs with a common prefix to table rows created (to be able to iterate through them using JavaScript in order to do some spreadsheet-like calculations).

I managed to get the ascending count into a variable named item.count, but I'm unable (even after searching quite a lot) to get that into the id= attribute of <tr>.

Using <tr id='item-<xsl:value-of select="$item.count" />'> I got a "not well-formed" message from Firefox.

The template in question looks like this:

  <xsl:template match="item">
    <xsl:variable name="item.count" select="count(preceding::item)" />'
    <tr id='item-<xsl:value-of select="$item.count" />'>
      <xsl:comment><xsl:value-of select="$item.count" />: <xsl:value-of select="." /></xsl:comment>
      <xsl:apply-templates select="./*"/>
      <!-- ... -->
      <td>(output)</td>
    </tr>
  </xsl:template>

(The comment is just to verify that the counter works as intended for now)

0

There are 0 best solutions below