title: How to use for loop in xslt
body: <p>How to use <code>xsl:for-each</code> in xslt to get value iteratively from an xml file and to dispaly it in table fromat</p>
  
  <p>For example: the xml file is like </p>
  
  <pre><code>&lt;order&gt;
    &lt;item name ="a"/&gt;
    &lt;item name ="b"/&gt;  
    &lt;item name ="c"/&gt;
    &lt;item name ="d"/&gt;
    &lt;item name ="e"/&gt;
    &lt;item name ="f"/&gt;
    &lt;item name ="g"/&gt;
  &lt;/order&gt;
  </code></pre>
  
  <p>and the output should be</p>
  
  <pre><code>  a    b    c   d
  
    e    f    g
  </code></pre>
  
  <p>the loop should count the item and if it is divisble by 4 it </p>
  
  <p>should close the current row and add a new row and so on..</p>
  
  <p>i'm using the following xslt for this</p>
  
  <p>but i can not display it in table format</p>
  
  <pre><code>   &lt;xsl:template match="/"&gt;
      &lt;html&gt;
      &lt;body&gt;
       &lt;xsl:call-template name ="incr"&gt;
          &lt;xsl:with-param name ="value"&gt;1&lt;/xsl:with-param&gt;
          &lt;xsl:with-param name ="limit"&gt;
            &lt;xsl:value-of select ="count(//item)"/&gt;
          &lt;/xsl:with-param&gt;
        &lt;/xsl:call-template&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  &lt;/xsl:template &gt;
  &lt;xsl:template name="incr"&gt;
    &lt;xsl:param name="value"/&gt;
    &lt;xsl:param name ="limit"/&gt;
    &lt;xsl:if test ="$value!=$limit+1"&gt;
      &lt;xsl:value-of select ="//item[$value]/@name"/&gt;
      &lt;xsl:if test ="$value mod 4 =0"&gt;
        &lt;br/&gt;
        &lt;br/&gt;
      &lt;/xsl:if&gt;
      &lt;xsl:call-template name ="incr"&gt;
        &lt;xsl:with-param name ="value" select ="$value+1"/&gt;
        &lt;xsl:with-param name ="limit" select ="$limit"/&gt;
      &lt;/xsl:call-template&gt;
    &lt;/xsl:if&gt;
  
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>please help me to do this</p>
  
  <p>Thanks in advance</p>