Java Reference
In-Depth Information
It executes its enclosing activities according to a counter. The counter is specified with start
and final values, and the loop runs the number of times equal to final minus start plus
one; this value gets assigned to the attribute counterName on each iteration. Here's how that
looks:
<forEach counterName="i">
<startCounterValue>1</startCounterValue>
<finalCounterValue>
count($order.document/items/lineItem)
</finalCounterValue>
...
</forEach>
The counter is important because it allows you to reference nodes in lexical order using the
variable value in an XPath expression. For example, you can use the following query to drill
down to the current line item given a set of line items in an order:
<forEach counterName="i">
<startCounterValue>1</startCounterValue>
<finalCounterValue>
count($order.document/items/lineItem)
</finalCounterValue>
< scope>
<sequence>
<assign>
<copy>
<from variable="order"
part="document"
query="/items/lineItem[$i]/partNumber"/>
<to variable="part" />
</copy>
</assign>
<invoke partnerLink="Supply" ... />
</sequence>
</scope>
</forEach>
An important thing to note about <forEach> is that it is only allowed to have a <scope> activ-
ity as its child, in contrast to the other structured activities, which are allowed any activities as
their children.
Search WWH ::




Custom Search