ユーザー定義XPath拡張関数の作成

Oracle SOA Suiteで使用するためのユーザー定義(カスタム)XPath拡張関数を作成できます。これらの関数は、次のコンポーネントに対して作成できます。

  • Oracle BPEL Process Manager

  • Oracle Mediator

  • XSLTマッパー

  • ヒューマン・ワークフロー

  • これらのすべてのコンポーネントで共有

Oracle SOA SuiteのXPath拡張関数は、次の標準に従います。

  • 単一のスキーマで、システム関数とユーザー定義関数の両方の構成構文を定義します。

  • XPath関数は、使用方法(Oracle BPEL Process ManagerOracle Mediator、ヒューマン・ワークフロー、XSLTマッパーおよびすべてで共通使用)に基づいて分類されます。

  • システム関数は、ユーザー定義関数と区別されます。

  • リポジトリで、システム関数の構成ファイルとユーザー定義関数の構成ファイルの両方をホストします。

  • リポジトリで、ユーザー定義関数の実装JARファイルをホストし、自動的にJava仮想マシン(JVM)(クラス・ローダー)で使用できるようにします。

関数の作成に関する次の規則に従うことをお薦めします。

  • 可能な場合は、すべてのコンポーネントで共有できる関数を作成します。すべてのコンポーネントで共有される関数は、ext-soa-xpath-functions-config.xmlという構成ファイルに作成できます。XSLTマッパーの関数は、Oracle BPEL Process ManagerOracle Mediatorおよびヒューマン・ワークフローの関数と異なる方法で実装する必要があります。

    これらの実装の相違点の詳細は、「ユーザー定義XPath拡張関数の実装方法」を参照してください。

  • あるコンポーネント用で他のコンポーネントでは使用できない関数(たとえば、Oracle Mediatorまたはヒューマン・ワークフローで使用できないOracle BPEL Process Manager用の関数)を作成する場合は、その関数をそのコンポーネントに固有の構成ファイルに作成します。この例では、Oracle BPEL Process Managerの関数をext-bpel-xpath-functions-config.xmlという構成ファイルに作成する必要があります。

タイプおよび等価のJavaタイプは、パラメータと戻り値に対して使用できます:

XML構成ファイルのタイプ名 Javaタイプ

string

java.lang.String

boolean

boolean

number

intfloatdouble

node-set

oracle.xml.parser.v2.XMLNodeList

tree

oracle.xml.parser.v2.XMLDocumentFragment

次の例は、システム関数およびユーザー定義関数で使用される関数スキーマを示しています。

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
 xmlns:tns="http://xmlns.oracle.com/soa/config/xpath" 
 targetNamespace="http://xmlns.oracle.com/soa/config/xpath"
 elementFormDefault="qualified">
      <element name="soa-xpath-functions" type="tns:XpathFunctionsConfig"/>
      <element name="function" type="tns:XpathFunction"/>
      <complexType name="XpathFunctionsConfig">
            <sequence>
               <element ref="tns:function" minOccurs="1" maxOccurs="unbounded"/>
            </sequence>
            <attribute name="resourceBundle" type="string"/>
            <attribute name="version" type="string"/>
      </complexType>

      <complexType name="XpathFunction">
            <sequence>
                 <element name="className" type="string"/>
                 <element name="return">
                         <complexType>
                                 <attribute name="type" type="tns:XpathType"
                                     use="required"/>
                         </complexType>
                 </element>
                 <element name="params" type="tns:Params" minOccurs="0"
                         maxOccurs="1"/>
                 <element name="desc">
                         <complexType>
                                 <simpleContent>
                                         <extension base="string">
                                                 <attribute name="resourceKey"
                                                     type="string"/>
                                         </extension>
                                 </simpleContent>
                         </complexType>
                 </element>
                 <element name="detail" minOccurs="0">
                         <complexType>
                                 <simpleContent>
                                         <extension base="string">
                                                 <attribute name="resourceKey"
                                                      type="string"/>
                                         </extension>
                                 </simpleContent>
                         </complexType>
                 </element>
                 <element name="icon" minOccurs="0">
            <complexType>
                     <simpleContent>
                              <extension base="string">
                                    <attribute name="resourceKey"
                                       type="string"/>
                              </extension>
                     </simpleContent>
             </complexType>
        </element>
                      <element name="helpURL" minOccurs="0">
             <complexType>
                      <simpleContent>
                              <extension base="string">
                                    <attribute name="resourceKey"  
                                       type="string"/>
                              </extension>
                      </simpleContent>
              </complexType>
        </element>
        <element name="group" minOccurs="0">
              <complexType>
                      <simpleContent>
                              <extension base="string">
                                   <attribute name="resourceKey" type="string"/>
                              </extension>
                      </simpleContent>
              </complexType>
        </element>
        <element name="wizardClass" type="string" minOccurs="0"/> 
</sequence>
<attribute name="name" type="string" use="required"/>
               <attribute name="deprecated" type="boolean" use="optional"/>
</complexType>

      <complexType name="Params">
      <sequence>
              <element name="param" minOccurs="1" maxOccurs="unbounded">
                      <complexType>
                           <attribute name="name" type="string" use="required"/>
                           <attribute name="type" type="tns:XpathType"
                                 use="required"/>
                           <attribute name="minOccurs" type="string"
                                 default="1"/>
                           <attribute name="maxOccurs" type="string"
                                 default="1"/>
                           <attribute name="wizardEnabled" type="boolean"
                                 default="false"/>
                      </complexType>
              </element>
       </sequence>
  </complexType>
  <simpleType name="XpathType">
       <restriction base="string">
               <enumeration value="string"/>
               <enumeration value="boolean"/>
               <enumeration value="number"/>
               <enumeration value="node-set"/>
               <enumeration value="tree"/>
       </restriction>
  </simpleType>
</schema>