Re: [xsl] Returning a document fragment from Xalan extension function

Subject: Re: [xsl] Returning a document fragment from Xalan extension function
From: "Michal Urban" <michalurban@xxxxxxxxxxx>
Date: Wed, 11 Jun 2003 15:15:13 -0400
Thanks Joseph for your reply.

I knew about the Xalan documentation, however another look made me aware of
the real problem in my whole set-up: Java extension function returning Node
or the like is OK, however the return value better be output by
<xsl:copy-of> in the stylesheet.

As you can probably guess, I was using <xsl:value-of>... my bad, sorry for
the confusion :-]

I mostly did XML2HTML so far, therefore only used a subset of XSLT...

Also thanks to Rob Koberg and his URIResolver idea, I found your HOW-TO in
the archive - I'll check it out!

Regards, Michal

----- Original Message ----- 
Date: Wed, 11 Jun 2003 09:05:47 -0400
From: Joseph Kesselman <keshlam@xxxxxxxxxx>
Subject: RE: [xsl] Returning a document fragment from Xalan extension
function

This might be a better question for Xalan's mailing list, and this may
differ from Xalan-J to Xalan-XSLTC to Xalan-C, but...

The return types from Xalan-j extension functions, and how they're
interpreted, are described at http://xml.apache.org/xalan-j/extensions.html
under "return values".  If your extension passes back an object that
implements org.w3c.dom.DocumentFragment, Xalan-J should iterpret it as a
Result Tree Fragment. If you pass back other DOM types, they will be
interpreted as Node Sets.

In XSLT 1.0, Node Sets and Result Tree Fragments are different datatypes
(though that distinction is expected to go away in XSLT 2.0, as "temporary
trees" replace both). So depending on what you want to do with the returned
value, you may need to use an extension function to convert one to the
other. The EXSLT node-set() function is the closest thing to a portable
solution currently available, and Xalan does support it, or you can use
Xalan's own nodeset() function. See
http://xml.apache.org/xalan-j/extensionslib.html#nodeset for some
documentation.

Hope that helps to get you pointed in the right direction...

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.

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


Current Thread