Subject:Summation in XSLT Author:Sam Sam Date:28 Feb 2006 03:04 AM Originally Posted: 27 Feb 2006 11:56 PM
Hi
Please do let me know as to how do we handle the following scenario,
Source XML
<?xml version="1.0" encoding="UTF-8" ?>
<root><
<del>
<value>
<p1>10</p1>
<p2>5</p2>
</value>
<value>
<p1>10</p1>
<p2>5</p2>
</value>
<value>
<p1>10</p1>
<p2>15</p2>
</value>
</del>
</root>
Target XML
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<del>
<value>35</value>
</del>
</root>
So basically what i am trying to achieve is, i will have to compare the value <p1> and <p2> and pick up the greater of the 2 and sum it up. So in our above example it becomes 10 + 10 + 15 = 35
How can this be achieved using XSLT 1.0.
regards
Sam
Subject:Summation in XSLT Author:Minollo I. Date:28 Feb 2006 10:07 AM
There are ways to do this in a much simpler way using XSLT 2.0; and probably also using XSLT 1.0; but this should do something similar to what you are looking for: