title: XSL iterate elements of same tag
body: <p>I'm learning XSD, and I tried to transform XML in HTML with bad results until now.
  I have this XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sales&gt;
    &lt;division id="North"&gt;
      &lt;revenue&gt;10&lt;/revenue&gt;
      &lt;growth&gt;9&lt;/growth&gt;
      &lt;bonus&gt;7&lt;/bonus&gt;
    &lt;/division&gt;
    &lt;division id="South"&gt;
      &lt;revenue&gt;4&lt;/revenue&gt;
      &lt;growth&gt;3&lt;/growth&gt;
      &lt;bonus&gt;4&lt;/bonus&gt;
      &lt;/division&gt;
    &lt;division id="West"&gt;
      &lt;revenue&gt;6&lt;/revenue&gt;
      &lt;growth&gt;-1.5&lt;/growth&gt;
      &lt;bonus&gt;2&lt;/bonus&gt;
    &lt;/division&gt;
  &lt;/sales&gt;
  </code></pre>
  
  <p>With XSL I want this:</p>
  
  <p><a href="https://i.stack.imgur.com/ZNRCp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZNRCp.png" alt="Expected Results"></a></p>
  
  <p>This is my XSL code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
    &lt;xsl:template match="/sales"&gt;
      &lt;table border = "1" &gt;
        &lt;tr&gt;
           &lt;th&gt;Division&lt;/th&gt;
           &lt;th&gt;Revenue&lt;/th&gt;
           &lt;th&gt;Growth&lt;/th&gt;
           &lt;th&gt;Bonus&lt;/th&gt;
        &lt;/tr&gt;
        &lt;xsl:apply-templates select ="/sales/division"/&gt;   
      &lt;/table&gt;  
    &lt;/xsl:template&gt;
   &lt;xsl:template match="/sales/division"&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;xsl:value-of select ="/sales/division/@id"/&gt; &lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select ="/sales/division/revenue"/&gt; &lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select ="/sales/division/growth"/&gt; &lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select ="/sales/division/bonus"/&gt; &lt;/td&gt;
      &lt;/tr&gt;
   &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>And I obtain this:</p>
  
  <p><a href="https://i.stack.imgur.com/vmoZ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vmoZ7.png" alt="Results"></a></p>
  
  <p>I tried also with:</p>
  
  <pre><code>&lt;xsl:for-each select ="/sales/division" &gt;
   &lt;tr&gt;
    &lt;td&gt;&lt;xsl:value-of select ="/sales/division/@id"/&gt; &lt;/td&gt;
    &lt;td&gt;&lt;xsl:value-of select ="/sales/division/revenue"/&gt; &lt;/td&gt;
    &lt;td&gt;&lt;xsl:value-of select ="/sales/division/growth"/&gt; &lt;/td&gt;
    &lt;td&gt;&lt;xsl:value-of select ="/sales/division/bonus"/&gt; &lt;/td&gt;
   &lt;/tr&gt;
  </code></pre>
  
  <p></p>
  
  <p>But I have same bad result.</p>