Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XSLT grouping and sum

$
0
0
My XML is
<accounting>
    <entry> 
<group>1</group>
        <vat>0</vat>
        <sum>80</sum>
    </entry>
    <entry>
<group>1</group>
        <vat>175</vat>
        <sum>90</sum>
    </entry>
    <entry>
<group>2</group>
        <vat>350</vat>
        <sum>10</sum>
</entry>
<entry>
<group>2</group>
        <vat>0</vat>
        <sum>20</sum>
    </entry>
</accounting>

My Expected Result is

<table>
    <tr> 
<th>group</th>
        <th>Vat</th>
        <th>Sum</th>
    </tr>
   <tr>  
<td>1</td>
        <td>0</td>
        <td>80</td>
    </tr>
    <tr>
<td>1</td>
        <td>175</td>
        <td>90</td>
    </tr>
    <tr>
<td>Subtotal</td>
        <td>175</td>
        <td>170</td>
    </tr>
    <tr>
<td>2</td>
        <td>350</td>
        <td>10</td>
    </tr>
    <tr>
<td>2</td>
        <td>0</td>
        <td>20</td>
    </tr>
    <tr>
<td>Subtotal</td>
        <td>350</td>
        <td>20</td>
    </tr>
    <tr>
<td>Grand Total</td>
        <td>525</td>
        <td>200</td>
    </tr>
</table>

Kindly give xlst script for this. Expected result is to get the total by group and subgroup.

Thanks in advance

Pratheeskumar C



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>