To dynamically change the value of element in a XML record you can manipulated the 'to:' element in the copy clause:
Normally you have:
This statement will fail if the the XML payload contains more than one row. Because the assigment is done on a single record. If we use a record counter that loops through this XML payload we are able to assign the specific record very easily. You can change copy in:
<copy>
<from variable="InputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:input"/>
<to variable="OutputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:ListOfOrders
/ns1:Order:/ns1:Amount"/>
</copy>
<copy>
<from variable="InputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:input"/>
<to variable="OutputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:ListOfOrders[$RecordCounter]
/ns1:Order:/ns1:Amount"/>
</copy>
The trick is to add the [$RecordCounter] directly in in the XPATH query of the copy activity. The BPEL PM will interprete this and translate this into the correct value.
Note: You must define the variable "RecordCounter" in your scope as an integer.