[jdom-interest] HTML Transformation from xml/xsl
Laurent Bihanic
laurent.bihanic at atosorigin.com
Wed Oct 3 00:58:21 PDT 2001
Hi,
JDOMSource allows to directly use a JDOM Document as input for a
transformation without requiring you to first serialize it to text with
XMLOutputter.
JDOMResult allows you to convert the output of a transformation into a JDOM
Document.
In your case, you can not use JDOMResult as the transformation output is HTML,
not XML. As your input XML is a file, JDOMSource would not help you either
unless you currently create that file from a JDOM Document just for the
purpose of applying the transformation. In that case, using JDOMSource will
boost the performances.
Laurent
Peter.H.Roberts at bbh.com wrote:
> Hello,
>
> I am currently using Xalan's Transformer Factory to output HTML from an XML/XSL transformation:-
>
> public void transform ( PrintWriter out, String xmlFile,String xslFile)
> throws IOException, java.net.MalformedURLException
> {
> System.out.println("transform JdomB6 " + CDSNJ.EOL +
> xmlFile + " " + CDSNJ.EOL + xslFile);
> // Output goes in the response stream.
> InputStream xmlStream = null;
> InputStream xslStream = null;
> try
> {
> TransformerFactory tFactory = TransformerFactory.newInstance();
> URL xmlURL = new URL( xmlFile );
> java.net.URLConnection xmlURLConn = xmlURL.openConnection();
> xmlStream = xmlURLConn.getInputStream();
> Source xmlSource = new StreamSource(xmlStream);
> URL xslURL = new URL( xslFile );
> java.net.URLConnection xslURLConn = xslURL.openConnection();
> xslStream = xslURLConn.getInputStream();
> Source xslSource = new StreamSource(xslStream);
> // Generate the transformer.
> Transformer transformer = tFactory.newTransformer(xslSource);
> // Perform the transformation, sending the output to the response.
> transformer.transform(xmlSource, new StreamResult(out));
> } catch (Exception e) {
> out.write(e.getMessage());
> e.printStackTrace(out);
> } finally {
> xmlStream.close();
> xslStream.close();
> }
> }
>
> Is this the preffered way of doing this, I see you have added new JDOMResult and JDOMSOurce but these only create Dom's after a transform.
>
> Peter.
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
>
--
wWw
(o o)
-------------ooO-(_)-Ooo-----------------------------------------------
Laurent Bihanic | Tel: +33 (0)1 55.91.21.93 (Direct line)
Atos Origin | +33 (0)1 55.91.20.00
Intégration - e-Business | Fax: +33 (0)1 55.91.22.31
Les Miroirs - Bat. C |
18, avenue d'Alsace |
F-92926 La Defense Cedex | e-Mail: laurent.bihanic at atosorigin.com
-----------------------------------------------------------------------
"Microsoft isn't the answer. Microsoft is the question and the answer
is no."
DISCLAIMER:
The opinions expressed are entirely my own and may not necessarily be
those of my employer. Also, I am not now nor have I ever been a
lawyer. My opinions are provided as-is with absolutely no warrantee of
merchantability or fitness for any particular use. Besides, you can't
prove I typed this. No body saw me type this. Who says I typed this?
More information about the jdom-interest
mailing list