- Developing SOA Applications with Oracle SOA Suite
- XPath Extension Functions
- Creating User-Defined XPath Extension Functions
- How to Configure User-Defined XPath Extension Functions
How to Configure User-Defined XPath Extension Functions
To configure user-defined XPath extension functions:
- Create an XPath extension configuration file in which to define the function. The following example shows a sample configuration file that follows the function schema shown in Creating User-Defined XPath Extension Functions. In this example, two functions are created:
mf:myFunction1andmf:myFunction2.<?xml version="1.0" encoding="UTF-8"?> <soa-xpath-functions resourceBundle="myPackage.myResourceBundle" xmlns="http://xmlns.oracle.com/soa/config/xpath" xmlns:mf="http://www.my-functions.com"> <function name="mf:myFunction1"> <className>myPackage.myFunctionClass1</className> <return type="node-set"/> <params> <param name="p1" type="node-set" wizardEnabled="true"/> <param name="p2" type="string"/> <param name="p3" type="number" minOccurs="0"/> <param name="p4" type="boolean" minOccurs="0" maxOccurs="3"/> </params> <desc resourceKey="func1-desc-key">this is my first function</desc> <detail resourceKey="func2-long-desc-key">my first function does ... </detail> <icon>myPackage/resource/image/myFunction1.png</icon> <group resourceKey="func-group-key">My Function Group</group> <wizardClass>myPackage.myWizardClass1</wizardClass> </function> <function name="mf:myFunction2"> <className>myPackage.myFunctionClass2</className> <return type="string"/> <params> <param name="p1" type="node-set" wizardEnabled="true"/> <param name="p2" type="string"/> <param name="p3" type="number" minOccurs="0"/> <param name="p4" type="boolean" minOccurs="0" maxOccurs="unbounded"/> </params> <desc resourceKey="func2-desc-key">this is my second function</desc> <detail resourceKey="func2-long-desc-key">my second function does ...</detail> <icon>myPackage/resource/image/myFunction2.png</icon> <group resourceKey="func-group-key">My Function Group</group> <wizardClass>myPackage.myWizardClass2</wizardClass> </function> </soa-xpath-functions>
Table B-3 describes the elements of the configuration file. Each function configuration file uses
soa-xpath-functionsas its root element. The root element has an optionalresourceBundleattribute. TheresourceBundlevalue is the fully qualified class name of the resource bundle class providing national language support (NLS) for all function configurations.Table B-3 Function Schema Elements
Element Description classNameThe fully qualified class name of the function implementation class.
returnThe return type of the function. This can be one of the following types supported by XPath and XSLT:
string,number,boolean,node-set, andtree. For equivalent Java types, see the table at the beginning of this section (Creating User-Defined XPath Extension Functions.paramsThe parameters of the function. A function can have no parameters. A parameter has the following attributes:
-
name: The name of the parameter. -
type: The type of the parameter. This can be one of the following types supported by XPath and XSLT:string,number,boolean,node-set, andtree. For equivalent Java types, see the table at the beginning of this section (Creating User-Defined XPath Extension Functions. -
minOccurs: The minimum occurrences of the parameter. If set to0, the parameter is optional. If set to1, the parameter is required. The current restriction is that this attribute must only take a value of either0or1and that optional parameters must be defined after the required parameters. The default value is1if this attribute is absent. -
maxOccurs: The maximum occurrences of the parameter. If set tounbounded, the parameter can repeat anytime. This can support functions such as XPath 1.0 functionconcat(), which can take unlimited parameters. The current restriction is that no parameters except the last parameter of the function can havemaxOccursgreater than1orunbounded. The default value is1if this attribute is absent. -
wizardEnabled: Indicates whether to enable a wizard to enter the parameter value. This supports a user interface where the parameter value must be entered. If set totrue, a wizard launch button is rendered next to the parameter value field. The wizard launch button, when pressed, launches a popup wizard to help the user enter the parameter value. The wizard class must be specified later. The default value isfalseif this attribute is absent, meaning there is no wizard support for the parameter by default.
descAn optional description of the function. If the
resourceKeyis present, the description is retrieved from the resource bundle specified earlier on the root element.detailAn optional longer (detailed) description of the function. If the
resourceKeyis present, the description is retrieved from the resource bundle specified earlier on the root element.iconAn optional icon URL of the function. If the
resourceKeyis present, the icon URL is retrieved from the resource bundle specified earlier on the root element. This is to support a user interface in which the function must be displayed.helpURLAn optional help HTML URL of the function. If the
resourceKeyis present, the help URL is retrieved from the resource bundle specified earlier on the root element. This is to support a user interface in which the function help link must be displayed.groupAn optional group name of the function. If the
resourceKeyis present, the group name is retrieved from the resource bundle specified earlier on the root element. This is to support a user interface where functions must be grouped. If no group name is specified, the function falls into a built-in advanced functions group when being grouped in a user interface.wizardClassThe fully qualified class name of the wizard class for all parameters that are wizard-enabled. This is to support a user interface in which parameter values must be entered. This wizard class is invoked by wizard launch buttons to help you enter parameter values. If there is no wizard-enabled parameter, this element must be absent.
Note: This element is not supported for user-defined functions. Only system functions currently support this feature.
-
- Name your user-defined XPath extension configuration file based on the component type with which to use the function. Table B-4 describes the naming conventions to use for user-defined configuration files.
Table B-4 User-Defined Configuration Files
To Use with This Component... Use This Configuration File Name... Oracle BPEL Process Manager
ext-bpel-xpath-functions-config.xmlOracle Mediator
ext-mediator-xpath-functions-config.xmlXSLT Mapper
ext-mapper-xpath-functions-config.xmlHuman workflow
ext-wf-xpath-functions-config.xmlAll components
ext-soa-xpath-functions-config.xml - Place the configuration file inside a JAR file along with the compiled classes. Within the JAR file, the configuration file must be located in the
META-INFdirectory. The JAR file does not need to reside in a specific directory.Note:
The
customXpathFunctionJAR must be added explicitly as it is not part of the SOA composite. - In Oracle JDeveloper, go to Tools > Preferences > SOA.
- Click the Add button and select your JAR file.
- Restart Oracle JDeveloper for the changes to take effect.
The JAR file is automatically added to the JVM's class path to make it available for use.