Using the functions in the transformation operations

In this recipe, we will examine how the functions are used in the XSLT mapper. The functions provide a convenient way of transforming data in a BPEL process. In this recipe, we will use some of the available functions, such as the multiply operation and the if branch statement.

Getting ready

For this recipe, we will take the example from the Performing copy between the variables recipe. We will extend the example by using a function to add a margin to the rent price of the car.

How to do it…

The following steps describe the actions needed to use the functions in the XSLT transformations:

  1. Open the XSLT mapper in JDeveloper.
  2. We see that all the elements have the transformation links from the source to the target nodes. We delete the link that connects the price by clicking on the link and clicking on the Delete button.
  3. From the Component Palette on the right side, we choose the multiply mathematical function and drop it on the middle section of the XSLT mapper pane.

    Tip

    We can find the multiply function under the Mathematical Functions section in the Component Palette.

    We connect the input and output connector of the mathematical function, with the price node from the source and target schema respectively.

    How to do it…

    Note

    The source part of the variable is not connected to the multiply function. The reason for that is the usage of the source variable, which presents the array of strings. Since we took only one record from the array, JDeveloper deletes the link to the source variable.

  4. Finally, we need to set up the formula for the margin. We do this by double-clicking on the multiply function node. The dialog for entering the formula appears, we enter the formula text and confirm it by clicking on the OK button.
    How to do it…

We enter the source node into field 1 (/ns0:TempElement/ns0:pieces[4]) and insert the margin into field 2 (1.05).

How it works…

The functions we define in the XSLT mapper are stored in the XSL file. JDeveloper provides a convenient way of creating the transformation files. Behind the scenes, JDeveloper is building the XSL file. The XSLT mapper also performs real-time checking of the transformation file. For example, if we put the if xslt construct into the mapper pane, it immediately becomes marked with the error icon as shown in the following screenshot:

How it works…

The transformation file is, when finished, interpreted by the built-in XSLT engine when transforming the source variable to the target variable.

Oracle SOA Suite provides a number of functions that we can utilize for transformation purposes as follows:

Function Group

Description

Conversion Functions

Mainly contains the functions to convert the Boolean number and the string values.

Date Functions

Contains the date manipulation and formatting functions.

Logical Functions

This contains the logical operators such as <, >, =, true, false, or, not, and so on.

Mathematical Functions

Contains the mathematical functions such as abs, ceiling, sum, and so on.

Node-set Functions

This section enables various operations on the variables from the XML point of view. For example, the name function returns the name of the XML node.

String Functions

This section contains a number of string operation functions. Here, we also find the concat, compare, and contains functions.

XSLT Constructs

Contains the most important XSLT constructs. We find here the following constructs: choose, copy-of, for-each, if, otherwise, sort, variable, and when.

See also

  • The next recipe explains how to chain the functions.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset