title: counting sum with XSLT from XML row that have same items
body: <p>I'm sorry for my english, it's not native language so some word and term may be wrong.</p>
  
  <p>I have XML where is many items. and some items might be many times. I want it to be hatml table, but so that  same items are listet only once and the total has been summed up.</p>
  
  <p>Normal for-each is easy, but it just lists everything. How can i add some condition etc for my XSLT? </p>
  
  <p>Here is my example XML:</p>
  
  <pre><code>&lt;Amounts&gt;
      &lt;item&gt;
          &lt;id&gt;02&lt;/id&gt;
          &lt;name&gt;Item2&lt;/name&gt;
          &lt;amount&gt;20&lt;/amount&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;id&gt;01&lt;/id&gt;
          &lt;name&gt;Item1&lt;/name&gt;
          &lt;amount&gt;80&lt;/amount&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;id&gt;06&lt;/id&gt;
          &lt;name&gt;Item6&lt;/name&gt;
          &lt;amount&gt;50&lt;/amount&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;id&gt;02&lt;/id&gt;
          &lt;name&gt;Item2&lt;/name&gt;
          &lt;amount&gt;150&lt;/amount&gt;
      &lt;/item&gt;
  &lt;/Amounts&gt;
  </code></pre>
  
  <p>And here is my XSLT now:</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
      &lt;td&gt;id&lt;/td&gt;
      &lt;td&gt;name&lt;/td&gt;
      &lt;td&gt;total&lt;/td&gt;
  &lt;/tr&gt;
  &lt;xsl:for-each select="/Amounts/item"&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;xsl:value-of select="id"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;xsl:value-of select="name"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;xsl:value-of select="amount"/&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>But here is how i wan't it to be:</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
      &lt;td&gt;id&lt;/td&gt;
      &lt;td&gt;name&lt;/td&gt;
      &lt;td&gt;total&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;01&lt;/td&gt;
      &lt;td&gt;Item1&lt;/td&gt;
      &lt;td&gt;80&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;02&lt;/td&gt;
      &lt;td&gt;Item2&lt;/td&gt;
      &lt;td&gt;170&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;06&lt;/td&gt;
      &lt;td&gt;Item6&lt;/td&gt;
      &lt;td&gt;50&lt;/td&gt;
  &lt;/tr&gt;   
  &lt;/table&gt;
  </code></pre>