There is often need to pass variables from BPEL to XSL; in my case I was dealing a lot with file adapters and database adapters. I had to get the filename from file adapter and pass it to XSL so that it could be saved in database
Following are the steps to do so - :
1. Create a file anywhere and name it params.xsd (you can name it whatever u want)
2. Copy the following schema definition in the file
Note : Press ctrl+shift+l in jdeveloper for formatting
<assign name="assignPropertyValues1">
<copy>
<from>
<parameters xmlns="http://schemas.oracle.com/service/bpel/common">
<item>
<name>ParamOne</name>
<value/>
</item>
<item>
<name>ParamTwo</name>
<value/>
</item>
</parameters>
</from>
<to variable="varBpelXsl" query="/ns3:parameters"/>
</copy>
</assign>
<assign name="assignPropertyValues2">
<copy>
<from expression="substring-before(bpws:getVariableData('varFileName'),'_')"/>
<to variable="varBpelXsl"
query="/ns3:parameters/ns3:item[1]/ns3:value"/>
</copy>
<copy>
<from expression="bpws:getVariableData('varFileName')"/>
<to variable="varBpelXsl"
query="/ns3:parameters/ns3:item[2]/ns3:value"/>
</copy>
</assign>
3. In your BPEL create a variable e.g. varBpelXsl
- Choose variable type as Element
- Click on search option
- On the top right corner of the "Type Chooser" popup click on "Import Schema file"
- Browse for the params.xsd that you created above
- Select any partner link type (You have to do this as that is the only way that your schema is imported in BPEL)
4. Add the following code in your BPEL
<assign name="assignPropertyValues1">
<copy>
<from>
<parameters xmlns="http://schemas.oracle.com/service/bpel/common">
<item>
<name>ParamOne</name>
<value/>
</item>
<item>
<name>ParamTwo</name>
<value/>
</item>
</parameters>
</from>
<to variable="varBpelXsl" query="/ns3:parameters"/>
</copy>
</assign>
<assign name="assignPropertyValues2">
<copy>
<from expression="substring-before(bpws:getVariableData('varFileName'),'_')"/>
<to variable="varBpelXsl"
query="/ns3:parameters/ns3:item[1]/ns3:value"/>
</copy>
<copy>
<from expression="bpws:getVariableData('varFileName')"/>
<to variable="varBpelXsl"
query="/ns3:parameters/ns3:item[2]/ns3:value"/>
</copy>
</assign>
NOTE: The {ns3} above shall be replaced by the namespace provided to the schema definition imported while creating the variable
5. Modify the transform activity to include the 3rd parameter
<from expression="ora:processXSLT('xsl/transformationLoadProperty.xsl',bpws:getVariableData('varPropertyFile','body'),bpws:getVariableData('varBpelXsl'))"/>
6. Now to use the variable in XSL Mapping file
- Define two variable in the XSL before the XSL:template tag
<xsl:param name="ParamOne">
<xsl:param name="ParamTwo">
<xsl:param name="ParamTwo">
- Use the parameters as $ParamTwo and $ParamOne in your transformation
No comments:
Post a Comment