How to implement multi-source XSLT mapping in 11g BPEL
Posted
by [email protected]
on Oracle Blogs
See other posts from Oracle Blogs
or by [email protected]
Published on Wed, 14 Apr 2010 11:17:18 +0000
Indexed on
2010/04/14
13:03 UTC
Read the original article
Hit count: 1735
- Drag and drop a Transform Activity to a BPEL process
- Double-click on the Transform Activity, the Transform dialog window appears.
- Add source variables by clicking the Add icon and selecting the variable and part of the variable as needed. You can select multiple input variables. The first variable represents the main XML input to the XSL mapping, while additional variables that are added here are defined in the XSL mapping as input parameters.
- Select the target variable and its part if available.
- Specify the mapper file name, the default file name is xsl/Transformation_%SEQ%.xsl, where %SEQ% represents the sequence number of the mapper.
- Click OK, the xls file will be opened in the graphical mode. You can map the sources to the target as usual.
- Open the mapper source code, you will notice the variable representing the additional source payload, is defined as the input parameter in the map source spec and body
<mapSources>
<source type="XSD">
<schema location="../xsd/po.xsd"/>
<rootElement name="PurchaseOrder" namespace="http://www.oracle.com/pcbpel/po"/>
</source>
<source type="XSD">
<schema location="../xsd/customer.xsd"/>
<rootElement name="Customer" namespace="http://www.oracle.com/pcbpel/Customer"/>
<param name="v_customer" />
</source>
</mapSources>
...
<xsl:param name="v_customer"/> - Let's take a look at the BPEL source code used to execute xslt mapper.
<assign name="Transform_1">
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression="ora:doXSLTransformForDoc('xsl/Transformation_1.xsl',bpws:getVariableData('v_po'),'v_customer',bpws:getVariableData('v_customer'))"/>
<to variable="v_invoice"/>
</copy>
</assign> - You will see BPEL uses ora:doXSLTransformForDoc XPath function to execute the XSLT mapper.
This function returns the result of XSLT transformation when the xslt template matching the document. The signature of this function is ora:doXSLTransformForDoc(template,input, [paramQName, paramValue]*).
Where
template is the XSLT mapper name
input is the string representation of xml input,
paramQName is the parameter defined in the xslt mapper as the additional source
parameterValue is the additional source payload. - You can add more sources to the mapper at the later stage, but you have to modify the ora:doXSLTransformForDoc in the BPEL source code and make sure it passes correct parameter and its value pair that reflects the changes in the XSLT mapper.
So the best practices are :
- create the variables before creating the mapping file, therefore you can add multiple sources when you define the transformation in the first place, which is more straightforward than adding them later on.
- Review ora:doXSLTransformForDoc code in the BPEL source and make sure it passes the correct parameters to the mapper.
© Oracle Blogs or respective owner