title: xsl for-each: add code block every n rows?
body: <p>I am trying to transform a bit of xml which represents an image gallery into an html table. (it must be done with html and not with css).  <strong>How do I add the row break <code>&lt;/tr&gt;&lt;tr&gt;</code> every six or so columns with xsl?</strong></p>
  
  <p>I have this:</p>
  
  <pre><code>&lt;xsl:for-each select="//email/gallery" &gt;
  &lt;td&gt;
      &lt;img&gt;
      &lt;xsl:attribute name="src"&gt;
          &lt;xsl:value-of select="gallery-image-location"/&gt;
      &lt;/xsl:attribute&gt;
      &lt;xsl:attribute name="alt"&gt;
          &lt;xsl:value-of select="gallery-image-alt"/&gt;
      &lt;/xsl:attribute&gt;
      &lt;/img&gt;
  &lt;/td&gt;
  &lt;xsl:if test="????"&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
  &lt;/xsl:if&gt;
  &lt;xsl:for-each&gt;
  </code></pre>
  
  <p>In Javascript I would do something like:</p>
  
  <pre><code>for (i=0; i&lt;gallery.length; i++) {
      htm += '&lt;td&gt;&lt;img src="' +
      gallery[i].gallery-image-location +
      '" alt="'+ gallery[i].gallery-image-alt +'"&gt;&lt;/td&gt;';
  
      if (i%6 == 5 &amp;&amp; i != gallery.length-1) {
          htm += '&lt;/tr&gt;&lt;tr&gt;';
      }
  }
  </code></pre>