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

Laurent Bihanic laurent.bihanic at atosorigin.com
Mon Mar 5 02:08:36 PST 2001


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 
          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.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: transform.jar
Type: application/octet-stream
Size: 8481 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010305/95afcf51/transform.obj

More information about the jdom-interest mailing list