« SOAP FAQ | Main | XSLT 2.0 »

Passing BPEL Variable contents into XSLT as Parameters

Here is an interesting solution for passing content of BPEL variables into XSL Transformations as XSL Parameters.

XSL is executed using the XPath Extension Function ora:processXSLT. The two arguments for this extension function are as follows.

1) The XSL File Name
2) The source variable to be transformed [bpws:getVariableData(...)]

But there is one more argument that this XPath function can accept - 'properties'.
Note the signature of this function specified in xpath-functions.xml

Signature:  ora:processXSLT('template','input','properties'?).

These properties translate to XSL Parameters that can be accessed within the XSL Map using the construct
 <xsl:param name="<paramName>"/>

You can retrieve the value of this parameter within your XSLT in a way similar to the way used to extract data from XSL variables.

For e.g.  <Name><xsl:value-of select="$param1"/></Name>


 The "properties" argument of the XPath function is expected to be an XML Element that has the following structure.

Illustrated below is an example of such a properties XML.

<parameters xmlns:ns2="http://schemas.oracle.com/service/bpel/common" xmlns="http://schemas.oracle.com/service/bpel/common">

Within the XSLT, the parameters are accessible through their names. [in this case, the parameter names are "userName" and "location", and their values are "ramkmeno" and "CA" respectively.


1) Declare a variable that is of the abovementioned dataType [see XML above.]
2) Populate the variable with the contents of the BPEL variable you wish to pass into the XSLT
3) Invoke processXSLT() with the XSL File, source variable, and the parameters variable.
4) Access the parameter contents within the XSLT


BPEL Snippet

<!--Step 1: initialize the parameters variable from whatever BPEL variable whose information you need to access from within XSLT -->

<assign name="initializeXSLParameters">
      <from expression="ora:processXSLT('SetParams.xsl',
     <to variable="propertiesXMLVar"/>

<!--Step 2: Invoke the XSLT with the parameters as the third argument -->

<assign name="executeXSLT">
       <from expression="ora:processXSLT('TestXSLParams.xsl',
       <to variable="outputVariable" part="payload"/>

XSLT Snippet

<xsl:stylesheet version="1.0" ....>

  <xsl:param name="userName"/>
  <xsl:param name="location"/>

  <xsl:template match="/">
        <xsl:value-of select="concat('User : ', $userName, ' Location : ',$location)"/>


<TestXSLParamsProcessResponse xmlns:ns1="http://xmlns.oracle.com/TestXSLParams" xmlns="http://xmlns.oracle.com/TestXSLParams">
  <ns1:result>User : ramkmeno Location : CA</ns1:result>

« SOAP FAQ | Main | XSLT 2.0 »

hello I dont understand how to declare the propertiesXMLVar. can i download the bpel process code from somwhere?

Posted by yael on June 04, 2007 at 12:24 AM PDT #

Please find the BPEL Project that illustrates the functionality at the following link. http://blogs.oracle.com/ramkumarMenon/gems/TestXSLParams.zip the variable propertiesXMLVar is defined in the params.xsd as mentioned in the project.

Posted by Ramkumar Menon on June 04, 2007 at 04:54 AM PDT #

Hi Ramkumar, Actually when I tried the passing the parameters I skipped one of the step of populating the properties object and populated with a assign and was able to do that but that didn't work. I even tried replacing the transformation of populating with a simple assign, in your TestXSLParams project and it dint work. Please suggest me more on this and if you want to verify the mistake I am doing please also suggest me a web-location/mailid to put my code there. Thankyou

Posted by Joy on August 11, 2007 at 01:47 PM PDT #

Is this workaround still needed to be able to copy values from a known variable in the bpel-process in a transform-activity? Why can't I just use the 'xpath-expression' function to get the value of a variable? I should be able to reference all known variables within my bpel process inside a transform-activity and not only the attributes/values of the source. Kind regards, Nathalie

Posted by nathalie roman on February 05, 2008 at 06:59 PM PST #

BPEL variables are only available in the context of the BPEL process, and are not directly available in the context of XSLT.

Posted by Ramkumar Menon on February 13, 2008 at 03:57 AM PST #

Hi Ram, Thanks for the detailed example. Is it possible to transform all my BPEL process variables into this params file so that i can send this and access all of my variables in the transformation Thanks, shakram

Posted by shakram on March 04, 2008 at 12:27 AM PST #

You can only pass scalar content [strings] as parameters.

Posted by Ramkumar Menon on March 04, 2008 at 10:23 AM PST #

Hi Ram, First I´┐Żll give my scenario, please help me out. 1.xsd <orders> <crmorder> <orderId> <customerName> <phoneNumber> </crmorder> <Billingorder> <accNumber> <billPlan> <billType> </Billingorder> </orders> 2.xsd <service> <externalID> <InternalID> </service> 3.xsd <Final> <BillOrder> <Account> <orderId> <customerName> <phoneNumber> <accNumber> <billPlan> <billType> <externalID> </Account> <Service> <InternalID> <Status> </Service> </BillOrder> </Final> ------------------------------ for 1.xsd, I mapped to requestmessageType and variable is var1 for 2.xsd, I created new MessageType and variable var2 for 3.xsd ,I created new MessageType and Variable var3 ------------------------------ Now i need one Transformation,in that have to map both var1 and var2 to var3(1.xsd,2.xsd to 3.xsd) for this I have to use multiple sources to transformation but it is not possible.. I tried ur sample processees but getting error in first transformation. Thanks In Advance

Posted by Bhargavi on March 04, 2008 at 09:24 PM PST #

Hi Ram, Thanks for the example,it's very helpful.

Posted by Bhargavi on March 04, 2008 at 09:26 PM PST #

Great post. Keep up the great work !

Posted by Ed on April 10, 2008 at 03:45 PM PDT #

Hi, I have a question about this method. If you already have a source and target for the Transform activity (XSL), is it then possible to get these parameters available within the activity as well ? I have tried to do so, but can't get it to work. Seems the problem is I can only have 1 source, so either the source will be the result of a DB-adapter or the parametersXSL, ref from expression below: <assign name="executeXSLT"> <bpelx:annotation> <bpelx:pattern>transformation</bpelx:pattern> </bpelx:annotation> <copy> <from expression="ora:processXSLT('TestXSLParams.xsl', bpws:getVariableData('inputVariable','payload'), bpws:getVariableData('propertiesXMLVar'))"/> <to variable="outputVariable" part="payload"/> </copy> </assign>

Posted by HPN on August 26, 2008 at 07:47 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Principal Product Manager


« April 2014