Note: Currently, we only support single part which is an element for input message Note: User can use Mapper to create xpath in Init and Action/ChangeVariables, but tooling to use xpath in Assignment, Escalation, Notification, etc is yet to be added, user will need to type the xpath starting with "="
Task initialization section on task definition (.wf) file is optional, it consists of variable definitions and initialization.
<init> ( <variables> ... </variables>) ? ( <variable-init> ... </variable-init> ) ? + /init>
<variable-init> initializes a variable by assignment, similar to BPEL's assignment
<variable-init>
(<copy>
<from>VariableXpathExpression</from>
<to> VariableXpathExpression</to>
</copy>
)+
</variable-init>
VariableXpathExpression takes the form : $VariableName.partName{/Xpath expression}, for $TaskInput and $TaskOutput, partName can be omitted because $TaskInput and $TaskOutput always contain only one part, but Mapper supports xpath in the form of $VariableName.partName{/Xpath expression} only, thus it is the preferred to have partName
An example is to assign orderId from the input message to the output message to initialize the output message
<variable-init> <copy> <from>$TaskInput/orderId</from> <to>$TaskOutput/orderId</to> </copy> </variable-init>The binding of WLM variable to Xpath is similar to what BPEL does, the default xpath support is Xpath 1.0
Note: The variable initialization happens before the task is created and the variable once assigned can not be changed
<assignment>
<user>$TaskInput.part1/users</user>
<group>$TaskInput.part1/groups</group>
</assignment>
multiple users/groups can be obtained as a collection returned by the xpath, for example:
<sampleInput>
....
<users>
Mary
</users>
<users>
John
</users>
</sampleOutput>
When the input message is above, using $TaskInput.part1/users in assignment as <assignment><user>$TaskInput/users</user></assignment> also result in two assignees: Mary and John
The same rule applies to group.
The duration and deadline expression Timeout & Escalation can come from input message too, for example:
<sampleInput>
....
<deadline>
'2007-12-01T23:00:00Z'
</deadline>
</sampleOutput>
<escalation>
<deadline expressionLanguage="xpath">$TaskInput.part1/deadline</deadline>
... ...
</escalation>
Literals are constants expression with no variables. To indicate an expression is literal, the expression must be surrounded by quotes , for example:
<escalation>
<deadline expressionLanguage="xpath">'2007-12-01T23:00:00Z'</deadline>
... ...
</escalation>
<assignment>
<user>'Mary'</user>
<user>'John'</user>
<group>'CustomerServiceRep'</group>
</assignment>
we could use xpath 2.0 if else expression which will allow us to use if else without introducing if else constructs in task definition.
http://www.w3.org/TR/2003/WD-xpath20-20030502/#id-conditionals