Altova XMLSpy, testing custom functions in xsl transformations

In our middleware solutions (Oracle SOA Suite) we use a lot of xsl transformations.
Part of these transformations use database backend systems to do lookups for transforming internal values to external values (which can then be communicated to the customers).

In the Oracle SOA Suite you can create custom xsl function and store the jar in the domain/lib folder and then you will be able to use it in the xsl transformations.

We use Altova XMLSpy a lot for creating all these xsl transformations. To be able to test these custom functions in the xsl transformations you use the next in the xsl files to be able to execute the custom functions from within XMLSpy.

Simple example of how to call a java method to uppercase a string.

package nl.xenta.xsl;

public class Helper {
    public Helper() {
    }
    
    public static String formatName(String input) {
        return input.toUpperCase();
    }
}

And the xsl transformation calling the formatName method

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xenta="java:nl.xenta.xsl.Helper?path=jar:file:///c:/xsl_functions.jar!/">
	<xsl:template match="/">
		<root>
			<emp>
				<xsl:value-of select="xenta:formatName('testing')"/>
			</emp>
		</root>
	</xsl:template>
</xsl:stylesheet>

Use “java:” to add the jar file to the xsl.

Now we can test the xsl transformation without deploying the bpel with the transformation first and test it on runtime.

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

Comments are closed.