How to Determine Sequence Size

Manipulating XML Data in a BPEL Process 6-49 p:invoicep:line-item[2]p:line-total If the XPath is used trailing behind the bwps:getVariableDatafunction, the root element name does not need to be specified in the XPath. For example: bpws:getVariableDatainput, payloadp:line-item[2]p:line-total This is because the node returned by the getVariableData function is the root element. Specifying the root element name again in the XPath is redundant and is incorrect according to standard XPath semantics.

6.19.4.2 Using the bpelx:append Extension to Append New Items to a Sequence

The bpelx:append extension in an assign activity enables BPEL process service components to append new elements to an existing parent element. Example 6–94 provides an example. Example 6–94 bpelx:append Extension assign name=assign-3 copy from expression=bpws:getVariableDataidx+1 to variable=idx copy bpelx:append bpelx:from variable=partInfoResultVar part=payload bpelx:to variable=output part=payload bpelx:append ... assign The bpelx:append logic in this example appends the payload element of the partInfoResultVar variable as a child to the payload element of the output variable. In other words, the payload element of the output variable is used as the parent element.

6.19.4.3 Merging Data Sequences

You can merge two sequences into a single data sequence. This pattern is common when the data sequences are in an array that is, the sequence of data items of compatible types. The two append operations shown in Example 6–95 under assign demonstrate how to merge data sequences: Example 6–95 Data Sequences Merges with append Operations assign -- initialize mergedLineItems variable to an empty element -- copy from p:lineItems from to variable=mergedLineItems copy bpelx:append bpelx:from variable=input part=payload query=p:invoicep:lineItemsp:lineitem bpelx:to variable=mergedLineItems bpelx:append 6-50 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite bpelx:append bpelx:from variable=literalLineItems query=p:lineItemsp:lineitem bpelx:to variable=mergedLineItems bpelx:append assign

6.19.4.4 Generating Functionality Equivalent to an Array of an Empty Element

The genEmptyElem function generates functionality equivalent to an array of an empty element to an XML structure. This function takes the following arguments: genEmptyElemElemQName,int?, TypeQName?, boolean? Note the following issues: ■ The first argument specifies the QName of the empty elements. ■ The optional second integer argument specifies the number of empty elements. If missing, the default size is 1. ■ The third optional argument specifies the QName, which is the xsi:type of the generated empty name. This xsi:type pattern matches the SOAPENC:Array. If it is missing or is an empty string, the xsi:type attribute is not generated. ■ The fourth optional boolean argument specifies whether the generated empty elements are XSI - nil, provided the element is XSD-nillable. The default value is false. If missing or false, xsi:nil is not generated. Example 6–96 shows an append statement initializing a purchase order PO document with 10 empty lineItem elements under po: Example 6–96 append Statement bpelx:assign bpelx:append bpelx:from expression=ora:genEmptyElemp:lineItem,10 bpelx:to variable=poVar query=p:po bpelx:append bpelx:assign The genEmptyElem function in Example 6–96 can be replaced with an embedded XQuery expression, as shown in Example 6–97 . Example 6–97 Embedded XQuery Expression ora:genEmptyElemp:lineItem,10 == for i in 1 to 10 return p:lineItem The empty elements generated by this function are typically invalid XML data. You perform further data initialization after the empty elements are created. Using the same example above, you can perform the following: ■ Add attribute and child elements to those empty lineItem elements. ■ Perform copy operations to replace the empty elements. For example, copy from a web service result to an individual entry in this equivalent array under a flowN activity.