I have always wondered, it would be great to pass runtime variable data from the BPEL process to a XSL file for processing within the transformation. To achieve this you can follow the steps as given below;
1. Create a custom schema (namely xslproperties.xsd) as given below & import this schema into your 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>
2. Create a variable (for instance, xslParameters) in your BPEL process of type xslproperties.xsd
3. Now, assign the values to this schema using a transformation activity. You can assign the variable name to the <name> element & variable value to the <value> element
4. If you have to pass multiple variables to the XSL, use the for-each element in the transformation. Optionally you can also build the schema using the "XML Fragment" assign operation and assign values to it
5. The processXSLT() function has 3 parameters. The first parameter holds the XSL file name, the second parameter is the input variable/data for the XSLT to process and the third parameter is the properties. We are now interested in the third parameter which helps us to pass the BPEL variables to the XSLT.
6. Pass the variable xslParameters (As created in step 2) as the third parameter as shown below;
ora:processXSLT('XSLT_File.xsl',bpws:getVariableData(’inputVariable’,'payload’),bpws:getVariableData('xslParameters '))
7. Now, you can obtain all the variable values inside the XSLT file using the <xsl:param name="variable1"/> instruction and you can use this just like a variable inside your XSL file
1. Create a custom schema (namely xslproperties.xsd) as given below & import this schema into your 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>
2. Create a variable (for instance, xslParameters) in your BPEL process of type xslproperties.xsd
3. Now, assign the values to this schema using a transformation activity. You can assign the variable name to the <name> element & variable value to the <value> element
4. If you have to pass multiple variables to the XSL, use the for-each element in the transformation. Optionally you can also build the schema using the "XML Fragment" assign operation and assign values to it
5. The processXSLT() function has 3 parameters. The first parameter holds the XSL file name, the second parameter is the input variable/data for the XSLT to process and the third parameter is the properties. We are now interested in the third parameter which helps us to pass the BPEL variables to the XSLT.
6. Pass the variable xslParameters (As created in step 2) as the third parameter as shown below;
ora:processXSLT('XSLT_File.xsl',bpws:getVariableData(’inputVariable’,'payload’),bpws:getVariableData('xslParameters '))
7. Now, you can obtain all the variable values inside the XSLT file using the <xsl:param name="variable1"/> instruction and you can use this just like a variable inside your XSL file
hi,
ReplyDeleteThis technique works well.But there is a problem.
When i edit the process in the bpel view, the third parameter sent from the bpel to the xslt vanishes.
Can you tell me why?
It's a bug in Jdeveloper. Don't edit it in the visual editor but directly in the code.
DeleteTwo things to note;
ReplyDelete1. Have you managed to create & set the parameters in BPEL before calling processXSLT() method?
2. If (1) is yes, have you retrieved the parameters set from BPEL in your XSLT?
yes....i have passed two variables in name-value pairs through a parameter viz 'l_OA_param' set in bpel and passed that parameter viz 'l_OA_param' as the third parameter in the XSLT call from BPEL.
ReplyDeleteAlso i have used both name-value pairs in the xslt. there is no problem there.
Problem is when i try to open the xslt from bpel via the edit transformation option, the third parameter sent vansihes.
If i am not clear, do let me know.
i cannot share the entire code...probably make an example snippet
i have followed both the steps mentioned above...but the problem is when i edit the transformation from bpel view, i.e, i open the transformation box in bpel and do edit transformation, the third parameter sent vanishes without a trace...this problems occurs everytime....
ReplyDeletei have followed both the steps mentioned above...but the problem is when i edit the transformation from bpel view, i.e, i open the transformation box in bpel and do edit transformation, the third parameter sent vanishes without a trace...this problems occurs everytime....
ReplyDeleteYeah... I think it should be a problem with the Transformation node in the BPEL editor. You can try to edit the function in normal text mode and then try invoking it from a assign node? It should work.
ReplyDeletemy parameter has 2 child nodes, how do i call those child nodes within the xslt?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIn your XSL map, just add the following construct
ReplyDelete<xsl:param name="var1"/>
<xsl:param name="var1"/>
[Note that var1 & var2 here refer to the two nodes that you pass from BPEL]
Then you can access these within your XSLT, just like any other XSL variable;
<xsl:value-of select="$var1"/>