[jdom-interest] Implementation of JAXP TraX Source and Result for JDOM

Jason Hunter jhunter at collab.net
Mon Mar 5 15:08:12 PST 2001


Cool, as you probably saw this is a task listed in the TODO.  I'll look
the cover over in depth next chance I get.  In the meanwhile, everyone
out there doing transforms on JDOM documents should check this out! 
Report back to the list how well things work.

-jh-

Laurent Bihanic wrote:
> 
> Hi,
> 
> Please find attached an attempt to implement JAXP 1.1 TRaX source (JDOMSource)
> and result (JDOMResult) wrapping JDOM Documents.  These classes have been
> (lightly) tested with Xalan 2.0.0 and so far are OK.
> 
> With them, applying a stylesheet to a JDOM document is as simmple as:
> 
>     public static Document transform(Document in, String stylesheet) throws
> JDOMException
>     {
>        try
>        {
>           Transformer transformer =
> TransformerFactory.newInstance().newTransformer(new StreamSource(stylesheet));
> 
>           JDOMResult out = new JDOMResult();
> 
>           transformer.transform(new JDOMSource(in), out);
> 
>           return (out.getDocument());
>        }
>        catch (TransformerException ex1)
>        {
>           throw (new JDOMException("XSLT Trandformation failed", ex1));
>        }
>     }
> 
> I didn't know in which package(s) to put these classes but as JDOMResult needs
> SAXHandler which is only package-accessible in org.jdom.input I had to put
> JDOMResult in this package.  To be consistent, I put JDOMSource in
> org.jdom.output  ;o).
> 
> Jason, again, could SAXHandler be made public (maybe in
> org.jdom.input.helpers, org.jdom.sax.helpers or something similar) or at least
> a protected inner class of SAXbuilder?  Once this done, these classes can be
> moved anywhere.
> 
> Comments?
> 
> Laurent
> 
>   ------------------------------------------------------------------------
>                     Name: transform.jar
>    transform.jar    Type: Java Archive (application/java-archive)
>                 Encoding: base64



More information about the jdom-interest mailing list