rss
SOATUBE
Oracle
Custom Search SOABYTE here

Monday, April 18, 2011

Using ora:getPreference value in XSLT
















There is no direct approach to it.However,looking into ora:XSLT signature,I found that we can pass BPEL variables as properties.Alternatively,one can pass multiple inputs in SOA 11g.

First things first,

                   1.>   params.xsd needs to be imported to project folder.The schema is structures as below:--

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://schemas.oracle.com/service/bpel/common"
            targetNamespace="http://schemas.oracle.com/service/bpel/common"
            elementFormDefault="qualified">
  <!-- Root Element for Parameters -->          
  <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.> Define a variable of element type corresponding to above xsd. Let the name be parameterVar.

3    3.> Go to the composite.xml. Add the preference property as in the example below:--

  <component name="TestParams">
<implementation.bpel src="TestParams.bpel"/>
 <property name="bpel.preference.myPreference">HelloThere</property>
    </component>
4.                        
             4.>Go to the BPEL editor and drag a Assign activity. Following is how the resulting source code look like:--
                          <assign name="Assign_1">
            <copy>
                <from expression="indexName"/>
                <to variable=" parameterVar "
                    query="/ns4:parameters/ns4:item/ns4:name"/>
            </copy>
            <copy>
                <from expression="ora:getPreference('myPreference')"/>
                <to variable=" parameterVar "
                    query="/ns4:parameters/ns4:item/ns4:value"/>
            </copy>
        </assign>
5.                                                                                                                                                                                                                              

             5.> Drag a Transform activity. This will be the transformation from parameterVar to parameterVar. Map name to name and value to value inside transformation.
            <assign name="Transform_1">
            <bpelx:annotation>
                <bpelx:pattern>transformation</bpelx:pattern>
            </bpelx:annotation>
            <copy>
                <from expression="ora:processXSLT('xsl/Transformation_1.xsl',bpws:getVariableData(parameterVar))"/>
                <to variable=" parameterVar "/>
            </copy>
   </assign>
6.                                                                                                                                                                                                                                                                    

              6.>Once the above steps are completed. Next comes the passing of BPEL variable as third parameter in ora:XSLT signature. Inside the transformation, you need to add
 <xsl:param name=" indexName "/>. Note that indexname is same as assigned to name node of the  parameterVar.

Now this param can be used anywhere inside your XSLT by $indexName.


<assign name="MainXSLT">
            <bpelx:annotation>
                <bpelx:pattern>transformation</bpelx:pattern>
            </bpelx:annotation>
            <copy>
                <!-- Pass the additional Parameter <i> parameterVar </i> for the XSL Parameters -->
                <from expression="ora:processXSLT('TestParams.xsl',bpws:getVariableData('inputVariable','payload'),bpws:getVariableData(parameterVar))"/>
                <to variable="outputVariable" part="payload"/>
            </copy>
        </assign>

                     

0 comments:

Post a Comment

 
Blogger Profile