I am again providing you the requirement like this.
Could you please look into this?
<xml>
<test>
<BookID>
<BookID1>
<BookID2>
0061AB
</BookID2>
</BookID1>
</BookID>
<amount>
16
</amount>
</test>
<test>
<BookID>
<BookID1>
<BookID2>
0062CD
</BookID2>
</BookID1>
</BookID>
<amount>
2
</amount>
</test>
<test>
<BookID>
<BookID1>
<BookID2>
0061AB
</BookID2>
</BookID1>
</BookID>
<amount>
2
</amount>
</test>
</xml>
here According to the equal value of BookID, I want to add the amount value…..like for above example, if value of BookID is 0061AB, then the value of amount should be 18.
Edit (Pasted to Answer)
Output should be like this
<xml>
<test>
<BookID>
<BookID1>
<BookID2>
0061AB
</BookID2>
<BookID1>
</BookID>
<amount>
18
</amount>
</test>
<test>
<BookID>
<BookID1>
<BookID2>
0062CD
</BookID2>
<BookID1>
</BookID>
<amount>
2
</amount>
</test>
</xml>
I’m assuming you mean the sum of the amounts. You can do with with xpath like the below
Edit
You can parameterize the BookID by using a variable, or by using a call-template as per my answer to your previous question
The following stylesheet
Edit #2
It seems that you are now after grouping distinct elements and aggregating the totals.
Produces the output
Please can you take the time to read through the FAQ
Edit 3
This stylesheet will meet your latest requirement.