Search code examples
xpathbpel

Dynamic Assign in BPEL 2.0


Is it possible to dynamically generate an assign xpath from a variable and an XPath string.

ie.

<assign name="dynamicAssign">
    <copy>
        <from>$VariablePayload/$xpath_into_variable_payload</from>
        <to>...</to>
     </copy>
</assign>

Solution

  • No, it is not possible to feed in an XPath expression from a variable. What you could do instead is to rewrite your XPath in order to select elements whose names come from other variables. This however is still a quite static approach. To achieve this, you can use an XPath predicate together with the name() or local-name() function.

    e.g.:

    <assign name="dynamicAssign">
       <copy>
           <from>$VariablePayload/*[local-name() = $firstElementName]</from>
           <to>...</to>
        </copy>
     </assign>