XPath and Process Data
Use XPath syntax in an assign element to work with the process data.
In the assign element, the two attributes from and to are XPath expressions. The from attribute indicates the location in the source context from which the business process should pull a value. The to attribute indicates the location in the target context in which the process should place a value.
The source and target contexts for an assign element depend on whether the assign element is in an output element, an input element, or an assign activity.
- In an output element, the target context is the message that the process sends to a participant. The source context is the process data.
- In an input element, the target context is the process data and the source context is the message the process receives from a participant.
- In an assign activity, the process data is both the source context and the target context.
The numbered examples following this section are based on the following sample process data:
<ProcessData> <PurchaseOrder> <LineItem> <Price>12.34</Price> </LineItem> <LineItem> <Price>95.61</Price> </LineItem> <LineItem> <Price>34.52</Price> </LineItem> </PurchaseOrder> </ProcessData>
Count the number of line items and assign the count to a variable called LineItem.
<assign to="LineItem" from="count()"/>
Calculate the sum of the line items in the purchase order and assign it to a variable sum in the process data.
<assign to="sum" from="sum(PurchaseOrder/LineItem/Price)"/>
Extract the first line item and save it to LineItem1 in the process data.
<assign to="LineItem1" from=" PurchaseOrder/LineItem"/>