One of the readers of my blog post ‘Oracle Service Bus 11g, Using Custom Xpath Functions asked we can reuse the custom xpath functions in a xsl transformation.
It’s possibel to reuse the jar and calll the custom functions from within a xsl transformation.
Starting with creating the resources needed for the custom xpath function :
- XML Configuration file (osb-custom.xml)
- Property file (optional, osb-custom.properties)
- Custom Function Class (jar package)
Restart the osb service so the new jar will get loaded.
- Create a new osb project
- Create a new xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:cust="xalan://nl.xenta.osb.custom.functions.OsbUtils">
<xsl:variable name="param1" select="string('the beginning')"/>
<xsl:variable name="param2" select="string('the end')"/>
<xsl:template match="/">
<xsl:variable name="my_custom_concat" select="cust:customConcat($param1,$param2)" />
<the_result><xsl:value-of select="$my_custom_concat"/></the_result>
</xsl:template>
</xsl:stylesheet>
To be able to call a custom xpath function with the Xalan engine we need to add a new namespace_prefix + definition the the xsl
xmlns:cust="xalan://tests.pipeline.CustomXQFunctions"
- Start with xalan://
- Then the java package + classname, nl.xenta.osb.custom.functions.OsbUtils
- In the select of the value-of we eventually use the namespace-prefix + java method interface to call the java method, cust:customConcat($param1,$param2)
Create a new proxy service and use the xsl in for example an assing activity.
Deploy the service and use the testconsole to test it.



