processXSLT

This function returns the result of an XSLT transformation using the Oracle XDK XSLT processor.

The following example shows the 12c version of processXSLT:

<function name="ora:processXSLT">
 <className>com.collaxa.cube.xml.xpath.functions.xml.GetElementFromXDKXSLTFunction
 </className>
  <return type="node-set"/>
  <params>
   <param name="template" type="string"/>
   <param name="input" type="string"/>
   <param name="properties" type="string" minOccurs="0" maxOccurs="unbounded"/>
  </params>
  <desc resourceKey="PI_FUNCTION_DESC_PROCESSXSLT"></desc>
  <detail resourceKey="PI_FUNCTION_DESC_LONG_PROCESSXSLT">
        This function returns result of XSLT transformation by using Oracle XDK
        XSLT processor. 
        </detail>
  <group>BPEL XPath Extension Functions</group>
 </function>

Signature:

  • 12c version of the signature:

    ora:processXSLT('template','input','properties'?)

Arguments:

  • template: The XSLT template. Both HTTP and file URLs are supported.

  • input: The input data to be transformed.

  • properties: The properties that translate to XSL parameters that can be accessed within the XSL map using the construct <xsl:param name="paramName"/>. The properties are defined as follows:

    1. Create a params.xsd file to define the name-value pair (every property is a name-value pair). For example:

      <?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>
              <!-- Each Parameter is represented by an "item" node that contains
                   one unique name and a string value
              -->
              <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 SetParams.xsl file to populate the properties. Within the XSLT, the parameters are accessible through their names. For this example, the parameter names are userName and location, and the values are jsmith and CA, respectively.

      <?xml version="1.0" encoding="UTF-8" ?>
      <?oracle-xsl-mapper
        <mapSources>
          <source type="XSD">
            <schema location="TestXSLParams.xsd"/>
            <rootElement name="TestXSLParamsProcessRequest"
       namespace="http://xmlns.oracle.com/TestXSLParams"/>
          </source>
        </mapSources>
        <mapTargets>
          <target type="XSD">
            <schema location="params.xsd"/>
            <rootElement name="ArrayOfNameAnyTypePairType"
       namespace="http://schemas.oracle.com/service/bpel/common"/>
          </target>
        </mapTargets>
        <!-- GENERATED BY ORACLE XSL MAPPER 10.1.3.1.0(build 061009.0802) AT [WED
       APR 18 14:35:04 PDT 2007]. -->
      ?>
      <xsl:stylesheet version="1.0"
                      xmlns:ns2="http://schemas.oracle.com/service/bpel/common"
      xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services
      .functions.Xpath20"
      
                      xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:ora="http://schemas.oracle.com/xpath/extension"
      xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.
      headers.ESBHeaderFunctions"
                      xmlns:ns0="http://www.w3.org/2001/XMLSchema"
                      xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services
      .functions.ExtFunc"
                      xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
                      xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
                      xmlns:ns1="http://xmlns.oracle.com/TestXSLParams"
                      exclude-result-prefixes="xsl ns0 ns1 ns2 xp20 bpws ora ehdr
       orcl ids hwf">
        <xsl:template match="/">
          <ns2:parameters>
            <ns2:item>
              <ns2:name>
                <xsl:value-of select="'userName'"/>
              </ns2:name>
              <ns2:value>
                <xsl:value-of select="'jsmith'"/>
              </ns2:value>
            </ns2:item>
            <ns2:item>
              <ns2:name>
                <xsl:value-of select="'location'"/>
              </ns2:name>
              <ns2:value>
                <xsl:value-of select="'CA'"/>
              </ns2:value>
            </ns2:item>
          </ns2:parameters>
        </xsl:template>
      </xsl:stylesheet>
      
    3. Invoke SetParams.xsl from the .bpel file. For example:

      • Within assign activity initializeXSLParameters, you initialize the parameter variable from the specific BPEL variable whose information you want to access from within the XSLT.

      • Within assign activity executeXSLT, you invoke the XSLT with the parameters as the properties (third) argument of the function processXSLT.

      For example:

      <process name="TestXSLParams"
       . . .
       . . .
         <sequence name="main">
            <receive name="receiveInput" partnerLink="client"
               portType="client:TestXSLParams" operation="initiate"
               variable="inputVariable" createInstance="yes"/>
            <assign name="initializeXSLParameters">
               <bpelx:annotation>
                  <bpelx:pattern>transformation</bpelx:pattern>
               </bpelx:annotation>
               <copy>
                  <from expression="ora:processXSLT ('SetParams.xsl',
                     bpws:getVariableData('inputVariable','payload'))"/>
                  <to variable="propertiesXMLVar"/>
                  </copy>
            </assign>
            <assign name="executeXSLT">
               <bpelx:annotation>
                   <bpelx:pattern>transformation</bpelx:pattern>
               </bpelx:annotation>
      
               <copy>
                  <from expression="ora:processXSLT('TestXSLParams.xsl',
                     bpws:getVariableData('inputVariable','payload'),
                     bpws:getVariableData('propertiesXMLVar'))"/>
                   <to variable="outputVariable" part="payload"/>
               </copy>
            </assign>
            <invoke name="callbackClient" partnerLink="client"
               portType="client:TestXSLParamsCallback"
               operation="onResult"
               inputVariable="outputVariable"/>
         </sequence>
      </process>
      
    4. In a BPEL process, you use the properties to process the XSLT function.

Property IDs:

  • namespace-uri: http://schemas.oracle.com/xpath/extension

  • namespace-prefix: ora (for 12c)

You can use the ora:processXSLT function to write the results of large XSLT/XQuery operations to a temporary file in a directory system. The document is then loaded from the temporary file when needed. This eliminates the need for caching an entire document as binary XML in memory.

For more information, see Using XPath Functions to Write Large XSLT/XQuery Output to a File System.