This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

XslTransform Function

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Business Process profile samples and their artifacts is changed to <EI_HOME>/samples/business-process/.

Objective

This sample explains the usage of XslTransform() function.

Introducing XslTransform() Function

doXslTransform(string, node-set, (string, object)*) function is used to perform XSLT transformations, where BPEL variable values can be transformed into different schema. For more details on input parameters, refer to http://docs.oasis-open.org/wsbpel/2.0/CS01/wsbpel-v2.0-CS01.html#SA00039_table

Required name spaces:

doXslTransform() should be defined under "http://docs.oasis-open.org/wsbpel/2.0/process/executable" namespace.

Deploying the Sample

WSO2 BPS provides a sample, which can be deployed and executed to understand the function. Follow the instructions below to deploy and trigger the process.

1. Log in into BPS server management console and select "Processes -> Add" under the "Main" menu.

2. Upload the XslTransform.zip found in the BPS_Home/repository/samples/bpel directory. (Samples are also located at our sample repository).

3. In the "Deployed Processes" window, click the "Process ID" to access its "Process Information" window.

4. Under the "WSDL Details" widget, trigger the process using the "TryIt" link to create an instance of it.

Example Usage

Refer to XslTransform.zip and the example usage of the function as given below: 

<copy>
    <from>
        bpws:doXslTransform("HelloXslWorld.xsl", $myVar.TestPart, 'middle', $otherVar)
    </from>
    <tovariable="myVar"part="TestPart"/>
</copy>

In the above doXslTransform(), four parameters are passed.

  • HelloXslWorld.xsl - Style sheet file.
  • $myVar.TestPart - Input source to be transformed.
  • middle - Name of the object to be used in the transformation.
  • $otherVar - Object which will be referred as 'middle'.

The doXslTransform()function accepts pairs of string and objects, so that they can be referred in the style sheet. For example, in HelloXslWorld.xsl:

<xsl:value-ofselect="concat(*/content/text(), $middle, ' World')"/>