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

RE: [xsl] Calling a java function and returning a NodeList


Subject: RE: [xsl] Calling a java function and returning a NodeList
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Sat, 21 Sep 2002 12:20:11 +0100

> Can i return a Nodelist or a Node from a Java function to a 
> XSL. I want to return the Node or Nodelist using JAXP and not 
> go with any 
> specific XML Parser. I learnt that saxon needs NodeList built 
> using its own 
> parser. Is there any way around?. I want my java code and xsl 
> fully compiant 
> with JAXP and Trax API.

The most portable way of doing this is to use the document() function
with a URI of your own invention, along with a URIResolver that returns
the result in the form of a DOMSource, SAXSource, or StreamSource
object.

This is a bit tricky, though, if your function has complex parameters.
In this case you are stuck with using extension functions, and each XSLT
processor has its own rules for what arguments and return values it
accepts. Many XSLT processors will only accept DOM nodes that were
created by the same product, e.g. if you use the Oracle XSLT processor
you have to use the Oracle DOM implementation. Recent release of Saxon
allow an extension function to return a DOMSource, which can wrap any
DOM - but it's expensive.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords