Sometimes we do require to use the variables in the BPEL process into the xslt transformation but we cannot use bpws:getVariableData() function in the transform activity to fetch the values.
Here is a solution which I learned recently during my project.
The signature of the transform function is as below:
ora:processXSLT('template','input','properties'?).
Generally we only use the first two parameters i.e. template and input which is the name of the transformation file and the input parameter respectively. With the help of third parameter 'properties' we can pass the desired variables from the process to the xslt.
'properties' is an xml element which has name/value pairs. The xml is based on the following schema which we need to import in the BPEL process.
<xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://schemas.oracle.com/service/bpel/common"
xmlns="http://schemas.oracle.com/service/bpel/common"
targetNamespace="http://schemas.oracle.com/service/bpel/common"
elementFormDefault="qualified">
<xsd:element name="parameters">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Now we can assign the values to the name/value pair and pass the parameters element into the xslt.
The sample xml will look like:
<parameters>
<item>
<name>parameter1</name>
<value>value1<value>
</item>
<item>
<name>parameter2</name>
<value>value2</value>
</item>
<parameters>
Suppose the name of the xsl file is Transformation.xsl and the source variable is source then the transformation function will look as below:
ora:processXSLT('Transformation.xsl', bpws:getVariableData('source'),bpws:getVariableData('parameters'))
To access the passed values in the transformation we have to add xsl:param tag in the xsl file.
Open the xsl in the source view and add the following tag:
<xsl:param name="parameter1"/>
<xsl:param name="parameter2"/>
Now we can access the variables in the transformation by appending the '$' sign before the parameter for eg: $parameter1, $parameter2.
Hi Suryaveer
ReplyDeletefollowing your example...
i am getting the following err...
xdk:processXSLT('Transformation_1',bpws:getVariableData('V_claimno'),bpws:getVariableData('V_param','/ns6:parameters/ns6:item/ns6:claimNo')). The XPath expression failed to execute; the reason was: java.lang.String cannot be cast to org.w3c.dom.Element. Check the detailed root cause described in the exception message text and verify that the XPath query is correct.
what is the possible mistake i am committing...
Apologies for late reply. bpws:getVariableData('V_param','/ns6:parameters/ns6:item/ns6:claimNo') here you don't need to send the claimno you just need to send the root element.
ReplyDelete