How To Use Mathematical Calculations with XPath Standards

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 6-20 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite current XPath context node. In most cases, the true node does not exist. Therefore, an empty result node set is returned and the boolean function in XPath 1.0 converts an empty node set into a false result. This result can be potentially confusing.

6.12 Assigning a Date or Time

You can assign the current value of a date or time field by using the Oracle BPEL XPath function getCurrentDate, getCurrentTime, or getCurrentDateTime, respectively. In addition, if you have a date-time value in the standard XSD format, you can convert it to characters more suitable for output by calling the Oracle BPEL XPath function formatDate. For related information, see section 9.1.2 of the Business Process Execution Language for Web Services Specification Version 1.1 and section 8.3.2 of the Web Services Business Process Execution Language Specification Version 2.0.

6.12.1 How to Assign a Date or Time

Example 6–32 shows an example that uses the function getCurrentDate in BPEL 1.1. Example 6–32 Date or Time Assignment in BPEL 1.1 -- execute the XPath extension function getCurrentDate -- assign copy from expression=xpath20:getCurrentDate to variable=output part=payload query=invoiceinvoiceDate copy assign Example 6–33 shows an example that uses the function getCurrentDate in BPEL 2.0. Example 6–33 Date or Time Assignment in BPEL 2.0 assign copy fromxpath20:getCurrentDatefrom tooutput.payloadinvoiceDateto copy assign In Example 6–34 , the formatDate function converts the date-time value provided in XSD format to the string Jun 10, 2005 and assigns it to the string field formattedDate. Example 6–34 formatDate Function in BPEL 1.1 -- execute the XPath extension function formatDate -- assign copy from expression=ora:formatDate2005-06-10T15:56:00, MMM dd, yyyy to variable=output part=payload query=invoiceformattedDate copy assign