processXSLT

この関数は、Oracle XDK XSLTプロセッサを使用してXSLTトランスフォーメーションの結果を返します。

次の例は、12cバージョンの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>

シグネチャ:

  • 12cバージョンのシグネチャ:

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

引数:

  • template: XSLTテンプレート。HTTP URLとファイルURLの両方がサポートされています。

  • input: 変換する入力データ。

  • properties: コンストラクト<xsl:param name="paramName"/>を使用してXSLマップ内でアクセスできるXSLパラメータに変換されるプロパティ。プロパティは次のように定義されます。

    1. params.xsdファイルを作成し、名前/値ペアを定義します(どのプロパティも名前と値のペアです)。例:

      <?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. SetParams.xslファイルを作成してプロパティを移入します。XSLT内では、パラメータにはその名前を通じてアクセスできます。この例では、パラメータ名がuserNamelocationで、それぞれの値がjsmithCAです。

      <?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. .bpelファイルからSetParams.xslを呼び出します。例:

      • assignアクティビティinitializeXSLParameters内で、XSLT内からアクセス対象の情報を持つ特定のBPEL変数から、パラメータ変数を初期化します。

      • assignアクティビティexecuteXSLT内で、パラメータを関数processXSLTproperties (3番目)引数として、XSLTを呼び出します。

      例:

      <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. BPELプロセスでは、これらのプロパティを使用してXSLT関数にアクセスします。

プロパティID:

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

  • namespace-prefix: ora (12cの場合)

ora:processXSLT関数を使用すると、大きいXSLT/XQuery操作の結果をシステム・ディレクトリの一時ファイルに書き込むことができます。その後、ドキュメントは必要なときに一時ファイルからロードされます。これにより、ドキュメント全体をバイナリXMLとしてメモリーにキャッシュする必要がなくなります。

詳細は、「XPath関数を使用し、大きいXSLT/XQuery出力をファイル・システムに書き込み」を参照してください。