How to count the number of iterations in xsl:for-each
<p>Inside an <code>xsl:for-each</code> loop I need the number of iterations to put in a <code>rowspan</code> attribute.</p>

<p>Is there in <code>xsl</code> something similar to the following?</p>

<pre><code>for(int i = 0; i &lt; collection.length(); i++)
</code></pre>

<p>I came to</p>

<pre><code>&lt;xsl:for-each select="foo"&gt;
    &lt;xsl:if test="position()=1"&gt;
      &lt;td&gt;
        &lt;xsl:attribute name="rowspan"&gt;
          &lt;xsl:value-of select=...collection.length()...
            etc
</code></pre>

<p>so the running counter <code>i</code> is no problem. But in the first iteration I need to get the total number of iterations, or the analogy to <code>collection.length()</code>, for the <code>rowspan=</code> number.</p>