I need to:
input.xml (file below) to the format of output.xml
You need to link the quantities to their respective orders by matching the order id. The best way to do this is by using a key:
XSLT 1.0
Note that we are assuming that each order has no more than one quantity of each unit (i.e no summing is required). Also it seems to me that the target structure is less useful than what you're starting with.