I'm sorry for my english, it's not native language so some word and term may be wrong.
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.
Normal for-each is easy, but it just lists everything. How can i add some condition etc for my XSLT?
Here is my example XML:
<Amounts>
<item>
<id>02</id>
<name>Item2</name>
<amount>20</amount>
</item>
<item>
<id>01</id>
<name>Item1</name>
<amount>80</amount>
</item>
<item>
<id>06</id>
<name>Item6</name>
<amount>50</amount>
</item>
<item>
<id>02</id>
<name>Item2</name>
<amount>150</amount>
</item>
</Amounts>
And here is my XSLT now:
<table>
<tr>
<td>id</td>
<td>name</td>
<td>total</td>
</tr>
<xsl:for-each select="/Amounts/item">
<tr>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="amount"/></td>
</tr>
</table>
But here is how i wan't it to be:
<table>
<tr>
<td>id</td>
<td>name</td>
<td>total</td>
</tr>
<tr>
<td>01</td>
<td>Item1</td>
<td>80</td>
</tr>
<tr>
<td>02</td>
<td>Item2</td>
<td>170</td>
</tr>
<tr>
<td>06</td>
<td>Item6</td>
<td>50</td>
</tr>
</table>