Oracle Service Bus : Using custom xpath functions in xslt

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 :

  1. XML Configuration file (osb-custom.xml)
  2. Property file (optional, osb-custom.properties)
  3. 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.

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

One Response to “Oracle Service Bus : Using custom xpath functions in xslt”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>