As depicted in my previous post , on how to Assign a variable post xslt transformation , there might be a few better ways to perform the same.
Consider Student info case explained in the earlier post , I have my student_college in a Bpel.xml as a preference variable.
If we can manage to bring that variable into my transformation using a means , i don't need to perform the setText and have another assign activity below , which will be a performance upgrade.
Because what happens as the variable structure grows in the xslt file , the assign next to it will be a variable copy and it will take a considerable amount of time.
Here in this post , we will explain one better way , by which the same can be achieved with a slightly better performance.
Every time we perform the xslt transformation by selecting the input and output source variables , in the background the function used is ora:processXSLT().
The function is more or less similar to assign , only difference is it goes to an XSLT engine. If we take a more close look , the generic way to define or what we can call syntax for this function is
ora:processXSLT('template','input', ‘output’ 'properties'?) . The properties mentioned as fourth parameter to this function is not mandatory.
* Template is the xsl file
*input is the source Node
*Output is the target Node
*properties are what are defined in the bpel.xml
If we want to define some other variable which are not defined in the bpel.xml , we need to create a XSD for the same and then pass those variable.
The xslt engine input and output arguments should of type xsd/wsdl. It cannot take a simple string type.
So create a xsd called parameters.xsd , make it a name value/pair as shown below.
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://hatesoa.oracle.com/service/sampleSOAbpel"
xmlns="http://hatesoa.oracle.com/service/bpel/common"
targetNamespace="http://hatesoa.oracle.com/service/sampleSOAbpel"
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 go ahead and create a variable of this xsd and pass it as a fourth parameter in the ora:processXSLT function.
<assign name="transformation">
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression="ora:processXSLT('Transform.xsl',bpws:getVariableData('OutputVariable','OutputParameters'), bpws:getVariableData(‘parameters’))"/>
<to variable="outputVariable" part="payload"/>
</copy>
</assign>
**we need to populate the params variable before passing it as parameter
**We must define all the variables we need to use in the xslt using xsl:param function.
Consider Student info case explained in the earlier post , I have my student_college in a Bpel.xml as a preference variable.
If we can manage to bring that variable into my transformation using a means , i don't need to perform the setText and have another assign activity below , which will be a performance upgrade.
Because what happens as the variable structure grows in the xslt file , the assign next to it will be a variable copy and it will take a considerable amount of time.
Here in this post , we will explain one better way , by which the same can be achieved with a slightly better performance.
Every time we perform the xslt transformation by selecting the input and output source variables , in the background the function used is ora:processXSLT().
The function is more or less similar to assign , only difference is it goes to an XSLT engine. If we take a more close look , the generic way to define or what we can call syntax for this function is
ora:processXSLT('template','input', ‘output’ 'properties'?) . The properties mentioned as fourth parameter to this function is not mandatory.
* Template is the xsl file
*input is the source Node
*Output is the target Node
*properties are what are defined in the bpel.xml
If we want to define some other variable which are not defined in the bpel.xml , we need to create a XSD for the same and then pass those variable.
The xslt engine input and output arguments should of type xsd/wsdl. It cannot take a simple string type.
So create a xsd called parameters.xsd , make it a name value/pair as shown below.
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://hatesoa.oracle.com/service/sampleSOAbpel"
xmlns="http://hatesoa.oracle.com/service/bpel/common"
targetNamespace="http://hatesoa.oracle.com/service/sampleSOAbpel"
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 go ahead and create a variable of this xsd and pass it as a fourth parameter in the ora:processXSLT function.
<assign name="transformation">
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression="ora:processXSLT('Transform.xsl',bpws:getVariableData('OutputVariable','OutputParameters'), bpws:getVariableData(‘parameters’))"/>
<to variable="outputVariable" part="payload"/>
</copy>
</assign>
**we need to populate the params variable before passing it as parameter
**We must define all the variables we need to use in the xslt using xsl:param function.
No comments:
Post a Comment