[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How to: Returning HTML Elements From a Saxon Exten

Subject: RE: How to: Returning HTML Elements From a Saxon Extension Function (6.5.x)
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 17 Apr 2003 22:53:24 +0100
returning dom saxon
You should probably be asking this question on the Saxon list rather
than here, but here goes.

This is actually a lot easier in 7.4 than in 6.5.2. In 7.4 there are two
very easy solutions:

(1) call XPathEvaluator, you can give this any JAXP Source object, and
it will give you back a NodeInfo which you can return from your
extension function

(2) return the XML string to the stylesheet and call saxon:parse to
parse it into a tree.

In 6.5.2 you have to probe a little bit deeper to find the right
interfaces. I think the simplest way (because it involves least use of
Saxon-specific methods) is to do a JAXP identity transformation from any
Source object to a DOMResult, where the DOMResult is primed using
setNode() on a document node created using new
com.icl.saxon.TinyDocumentImpl(); you can then return this document node
as the result of your extension function.

Happy Easter,

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

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> W. Eliot Kimber
> Sent: 17 April 2003 19:39
> To: xsl-list
> Subject:  How to: Returning HTML Elements From a Saxon 
> Extension Function (6.5.x)
> 
> 
> I want to make sure I'm thinking about a small XSLT puzzle 
> correctly: my 
> requirement is to provide a Saxon extension function that returns a 
> restult tree (or a string that will become a result tree). What I'm 
> doing is building a navigation bar based on configuration information 
> held in an external file and accessed through an external 
> Java library.
> 
> If I just return the markup as a string (e.g., return "<a 
> href="#foo">bar</a>";) then it gets escaped, as you would expect.
> 
> Looking through the docs for extension functions, it appears 
> that I need 
> to return a NodeInfo node that contains nodes for the markup. 
> NodeInfo 
> is a Saxon-specific DOM implementation. The Saxon DOM 
> implementation is 
> read-only, and if I'm understanding the docs correctly, I 
> have to use a 
> SAX process to construct new nodes.
> 
> This leads to two questions:
> 
> 1. Is my analysis correct or have I missed some easy way to 
> return this 
> markup?
> 
> 2. If my analysis is correct, does anyone have an example of 
> doing this 
> sort of off-the-cuff SAX processing I could crib from? I 
> didn't find any 
>   examples in the Saxon-supplied samples.
> 
> Thanks,
> 
> Eliot
> -- 
> W. Eliot Kimber, eliot@xxxxxxxxxx
> Consultant, ISOGEN International
> 
> 1016 La Posada Dr., Suite 240
> Austin, TX  78752 Phone: 512.656.4139
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.