How to Access Fields Within Element-Based and Message Type-Based Variables

Manipulating XML Data in a BPEL Process 6-17 Example 6–21 Field Copying Levels in BPEL 2.0 assign copy frominput.payloadautoloan:applicationautoloan:customerfrom tocustomerto copy assign Example 6–22 shows how the BPEL file defines element-based variables involved in an assignment: Example 6–22 BPEL File Definition - Element-Based Variables variable name=customer element=tns:customerProfile

6.7 Assigning Numeric Values

You can assign numeric values in XPath expressions.

6.7.1 How to Assign Numeric Values

Example 6–23 shows how to assign an XPath expression with the integer value of 100. Example 6–23 XPath Expression Assignment assign -- copy from integer expression to the variable -- copy from expression=100 to variable=output part=payload query=p:resultp:quantity copy assign

6.8 Using Mathematical Calculations with XPath Standards

You can use simple mathematical expressions like the one in Section 6.8.1, How To Use Mathematical Calculations with XPath Standards, which increment a numeric value.

6.8.1 How To Use Mathematical Calculations with XPath Standards

In Example 6–24 , the BPEL XPath function getVariableData retrieves the value being incremented. The arguments to getVariableData are equivalent to the variable, part, and query attributes of the from clause including the last two arguments, which are optional. Example 6–24 XPath Function getVariableData Retrieval of a Value assign copy from expression=bpws:getVariableDatainput, payload, p:value + 1 to variable=output part=payload query=p:result copy assign You can also use variable syntax in BPEL 1.1, as shown in Example 6–25 : 6-18 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite Example 6–25 variable Syntax Use in BPEL 1.1 assign copy from expression=input.payload + 1 to variable=output part=payload query=p:result copy assign Example 6–26 shows how to use variable syntax in BPEL 2.0. Example 6–26 variable Syntax Use in BPEL 2.0 assign copy frominput.payload + 1from tooutput.payloadto copy assign

6.9 Assigning String Literals

You can assign string literals to a variable in BPEL.

6.9.1 How to Assign String Literals

The code in Example 6–27 copies a BPEL 1.1 expression evaluating from the string literal GE to the symbol field within the indicated variable part. Note the use of the double and single quotes. Example 6–27 Expression Copy in BPEL 1.1 assign -- copy from string expression to the variable -- copy from expression=GE to variable=output part=payload query=p:resultp:symbol copy assign Example 6–28 shows how to perform this expression in BPEL 2.0. Example 6–28 Expression Copy in BPEL 2.0 assign copy fromGEfrom tooutput.payloadp:symbolfrom copy assign

6.10 Concatenating Strings

Rather than copying the value of one string variable or variable part or field to another, you can first perform string manipulation, such as concatenating several strings. Manipulating XML Data in a BPEL Process 6-19

6.10.1 How to Concatenate Strings

The concatenation is accomplished with the core XPath function named concat; in addition, the variable value involved in the concatenation is retrieved with the BPEL XPath function getVariableData. In Example 6–29 , getVariableData fetches the value of the name field from the input variable’s payload part. The string literal Hello is then concatenated to the beginning of this value. Example 6–29 XPath Function getVariableData Fetch of Data assign -- copy from XPath expression to the variable -- copy from expression=concatHello , bpws:getVariableDatainput, payload, p:name to variable=output part=payload query=p:resultp:message copy assign Other string manipulation functions available in XPath are listed in section 4.2 of the XML Path Language XPath Specification.

6.11 Assigning Boolean Values

You can assign boolean values with the XPath boolean function.

6.11.1 How to Assign Boolean Values

Example 6–30 provides an example of assigning boolean values in BPEL 1.1. The XPath expression in the from clause is a call to XPath’s boolean function true, and the specified approved field is set to true. The function false is also available. Example 6–30 Boolean Value Assignment in BPEL 1.1 assign -- copy from boolean expression function to the variable -- copy from expression=true to variable=output part=payload query=resultapproved copy assign Example 6–31 provides an example of assigning boolean values in BPEL 2.0. Example 6–31 Boolean Value Assignment in BPEL 2.0 assign copy fromtruefrom tooutput.payloadapprovedto copy assign The XPath specification recommends that you use the true and false functions as a method for returning boolean constant values. If you instead use booleantrue or booleanfalse, the true or false inside the boolean function is interpreted as a relative element step, and not as any true or false constant. It attempts to select a child node named true under the