title: Rendering a node sequence as M x N table
body: <p>@Oded: Sorry to have been poor in my exposition... My input document has a fragment like this:</p>
  
  <pre><code>&lt;recordset name="resId" &gt;
  &lt;record n="0"&gt;example 1&lt;/record&gt;
  &lt;record n="1"&gt;example 2&lt;/record&gt;
  &lt;record n="2"&gt;example 1&lt;/record&gt;
  ....
  &lt;record n="N"&gt;example 1&lt;/record&gt;
  &lt;/recordset&gt;
  </code></pre>
  
  <p>containing an arbitrarily long  node sequence. The attribute "n" reports the order of the node in the sequence. I need to arrange as output that sequence in a M (rows) x N (columns) table and I have some trouble doing that. I cannot call a template </p>
  
  <pre><code>&lt;xsl:template match="recordset"&gt;
     &lt;table&gt;
        &lt;xsl:apply-templates select="record"/&gt;
     &lt;/table&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>with something like:</p>
  
  <pre><code>&lt;xsl:template match="record"&gt;
  &lt;xsl:if test="@n mod 3 = 0"&gt;
      &lt;tr&gt;
  &lt;/xsl:if&gt;
  ........
  &lt;td&gt;&lt;xsl:value-of select"something"&gt;&lt;/td&gt;
  </code></pre>
  
  <p>because code is invalid (and I should repeat it at the end of the template in some way)
  and I must put some (maybe too much) trust in the presence of the numbered attribute. Someone has a hint? Thanks!</p>