Merging XML records into one
- by BhanuPratap Tarigopula
I am new to XSLT. I have requirement of merging and adding.
XML:
<OrderDetails>
<OrderDetail action="add">
<OrderedUnits>18</OrderedUnits>
<Date>2013-09-30T00:00:00</Date>
<LocationCode>3202</LocationCode>
<PONumber>022548295755</PONumber>
</OrderDetail>
<OrderDetail action="add">
<OrderedUnits>12</OrderedUnits>
<Date>2013-09-30T00:00:00</Date>
<LocationCode>3202</LocationCode>
<PONumber>022548295755</PONumber>
</OrderDetail>
<IOrderDetail action="add">
<OrderedUnits>18</OrderedUnits>
<Date>2013-09-30T00:00:00</Date>
<LocationCode>3202</LocationCode>
<PONumber>022548295762</PONumber>
</OrderDetail>
<OrderDetails>
If the LocationCode, Date, and PONumber fields match, I need to add the OrderedUnits and make it only one entry.
Expected output XML:
<OrderDetails>
<OrderDetail action="add">
<OrderedUnits>30</OrderedUnits>
<Date>2013-09-30T00:00:00</Date>
<LocationCode>3202</LocationCode>
<PONumber>022548295755</PONumber>
</OrderDetail>
<IOrderDetail action="add">
<OrderedUnits>18</OrderedUnits>
<Date>2013-09-30T00:00:00</Date>
<LocationCode>3202</LocationCode>
<PONumber>022548295762</PONumber>
</OrderDetail>
<OrderDetails>
How can I write this XSLT?