XslTransform Function
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:
xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
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')"/>