By Bob Webster on Jun 07, 2011
JDeveloper supports the addition of custom XPath functions to extend the functions available in both
the XSLT Mapper and the Expression Builder.
Developers can implement new functions by writing Java methods which can then be easily integrated
into the JDeveloper graphical tooling.
Once the functions are registered with JDeveloper they appear
in the Component Palette in the User Defined section.
For example, this image shows the two custom functions in this posting displayed in the JDeveloper Component Palette.
The SOA Suite Developer's Guide does a nice job of explaining the configuration steps
for user-defined functions at the following link
This posting provides examples of two different custom functions: using SOA Suite 18.104.22.168
- A simple function for use with the XSLT Mapper
- A complex example that can be used with the expression builder in a BPEL, Mediator or Worklist component.
A Simple XSLT Mapper Function
The smiple function is named "checkDept", and its intended use is to provide a default department number of 999
if an employee is not assigned to a department
Mapper functions are defined in a configuration file named ext-mapper-xpath-functions-config.xml
The following lines define the function for use with JDeveloper and the SOA runtime Server
When complete the function can be used as a custom function displayed in the XLST editor.
A Complex Expression Builder Function Example
The sortEmployees is a more complex example that sorts a list of employees in ascending order based on their department code.
The data types manipulated by the function are defined by the following employee schema.
Expression Builder functions are placed in different files to restrict usage.
- Place definitions in the ext-bpel-xpath-functions-config.xml for use in BPEL Components.
- Place definitions in the ext-mediator-xpath-functions-config.xml for use in Mediator Components.
- Place definitions in the ext-wf-xpath-functions-config.xml for use in Human Workflow Components.
- Place definitions in the ext-soa-xpath-functions-config.xml for use in any of the above Components.
The following lines define the sortEmployee function for use with JDeveloper and the SOA runtime Server .
They are placed in a file named ext-soa-xpath-functions-config.xml file.
When complete the function can be used as a custom function in the expression builder.
The following image shows the sortEmployees function in a BPEL assign node.
Customer functions and their configuration files must be packaged in a Jar file and registered with both JDeveloper and the SOA Runtime Server.
The complete list of development and runtime configuration steps is too long for a blog post.
For a complete list of steps to create these functions see the Full Post