I am new to XSLT and need to sum the total price (Quantity * UnitPrice) of items based on ID from each orders, and print it at the end of each Item's group using XSLT 1.0. Here is my example XML
<Orders>
<Order>
<Reference>234</Reference>
<Item>
<ID>10</ID>
<Quantity>1</Quantity>
<UnitPrice>2</UnitPrice>
</Item>
<Item>
<ID>10</ID>
<Quantity>2</Quantity>
<UnitPrice>3</UnitPrice>
</Item>
<Item>
<ID>10</ID>
<Quantity>2</Quantity>
<UnitPrice>2</UnitPrice>
</Item>
<Item>
<ID>20</ID>
<Quantity>2</Quantity>
<UnitPrice>4</UnitPrice>
</Item>
</Order>
<Order>
<Reference>456</Reference>
<Item>
<ID>10</ID>
<Quantity>2</Quantity>
<UnitPrice>2</UnitPrice>
</Item>
<Item>
<ID>20</ID>
<Quantity>2</Quantity>
<UnitPrice>2</UnitPrice>
</Item>
</Order>
</Orders>
The desired output XML is below
<SAPOrders>
<Order>
<Reference>234</Reference>
<Item>
<Quantity>1</Quantity>
<UnitPrice>2</UnitPrice>
</Item>
<Item>
<Quantity>2</Quantity>
<UnitPrice>3</UnitPrice>
</Item>
<Item>
<Quantity>2</Quantity>
<UnitPrice>2</UnitPrice>
<Total>12</Notes>
</Item>
<Item>
<Quantity>2</Quantity>
<UnitPrice>4</UnitPrice>
<Total>8</Notes>
</Item>
</Order>
<Order>
<Reference>456</Reference>
<Item>
<Quantity>2</Quantity>
<UnitPrice>2</UnitPrice>
<Total>4</Notes>
</Item>
<Item>
<Quantity>2</Quantity>
<UnitPrice>2</UnitPrice>
<Total>4</Total>
</Item>
</Order>
</SAPOrders>