[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Using a Java Function in XSLT


Subject: Re: [xsl] Using a Java Function in XSLT
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Thu, 25 Oct 2007 14:19:36 +1000

Jeff Sese wrote:
Hi,

I have a java application that hyphenates words based on a wordlist. This application accepts an XML file as input and then use a sax filer to hyphenate the words. However, there was a new requirement that ask if the application can be changed so that instead of applying the hyphenation to the whole XML file, it will only hyphenate chunks of the XML file based on an XPath expression.

Now as my application accepts XML file, I was thinking if it is possible if I can pass a chunk of the XML file that matches a certain xpath to my application via XSLT (I want to apply templates to the now hyphenated XML chunk). Something to this effect:

<xsl:template match="some.node">
<xsl:variable name="copy.of" as="node()" select="."/>
<!-- xsl instruction to call my java app (don't know the correct syntax)-->
<xsl:apply-templates select="my:java-app($copy.of)"/>
</xsl:template>


Is this possible?
Depends on the processor you are using. I know Xalan has this capability and based on the link below, so does Saxon.

http://www.cafeconleche.org/books/xmljava/chapters/ch17s03.html

Be warned, it isn't pretty syntax. Every time I use it, I have to relearn it.


-- Kamal Bhatt


Current Thread
Keywords