The chaining functions

When performing the transformations, we sometimes find ourselves in a situation where there is no single operation to perform a transformation the way we want. For example, let's say we would like to first trim two strings and then concatenate them. Since we don't have a single function to perform the task, the XSLT mapper in JDeveloper offers us the functionality of the chaining functions. In this recipe, we will examine how to chain the functions in order to present the complete information from the source to the target content.

Getting ready

We will amend the example from the Using the functions in the transformation operations recipe. We will amend the BPEL process so that we now map the correct source content to the target content.

How to do it…

  1. We will perform the action of concatenating the price element with its money unit. First, we open the XSLT mapper.
  2. Then, pick the concat function from the Component Palette (String Functions). Place it in the box where we calculate the price element with the margin.
  3. Now, delete the link from the multiply function to the target price node by right-clicking on the line and clicking on Delete.
  4. Next, drag the connector line from the output of the multiply function to the input of the concat function.
  5. Connect the output of the concat function to the price element of the target part.
  6. We still need to configure the concat function. We right-click on the concat function and select Properties…. We leave the field 1 unchanged and into the field 2 we enter /ns0:TempElement/ns0:pieces[6].
  7. The properties dialog now shows the following content:
    How to do it…
  8. We confirm the properties by clicking on OK in the dialog.

How it works…

We are able to chain the functions in order to fulfill the needed transformation. JDeveloper, with its XSLT mapper, shows the chain of functions. However, the functions are interpreted as simple operations in the XSL file. Let us check the code from our XSL file, where we used the chaining as follows:

<client:price>
  <xsl:value-of select = "concat(/ns0:TempElement/ns0:pieces[5] * 1.05,/ns0:TempElement/ns0:pieces[6])"/>
</client:price>

We can see that there is no multiply function. It is simply a star sign indicating the multiply operation in XSLT. Furthermore, the concat function presents a standard operation for the string concatenation in the XSLT specification.

See also

  • Besides the built-in functions in JDeveloper, we can also use the user-defined functions. We will examine how to define and use the user-defined functions in JDeveloper in the next recipe.
..................Content has been hidden....................

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