cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@dti.net>
Subject Re: Servlet to XSL possible?
Date Wed, 23 Jan 2002 19:52:36 GMT
Glad I could help Bob.

Xalan approach certainly sounds do-able and (arguably) looks simpler.

Drawbacks are:

* that you're reinventing the wheel somewhat (after all, one of cocoon's core functions is
to be a servlet that performs XSLT transforms)

* you lose some of the architectural/conceptual benefits of cocoon (i.e., envisioning your
pages as pipelines of generator -> transformers -> serializers)


But you've got a job you've got to get done, so go with whatever gets the job done best for
you.


DR




At 01:26 PM 1/23/02 -0600, you wrote:
>David,
>     Thanks for your thoughts.  I am going to digest what you suggest
>further.  I think another approach that is clean, albeit no Cocoon, is to
>leave it as a servlet, and use xalan directly - something like:
>
>       // instantiate a TransformerFactory
>       javax.xml.transform.TransformerFactory tFactory =
>                 javax.xml.transform.TransformerFactory.newInstance();
>
>       // ?? somehow attach a StringBuffer to the source instead of a file
>       javax.xml.transform.Source xmlSource =
>                 new javax.xml.transform.stream.StreamSource
>                              (new
>java.net.URL("file:foo.xml").openStream());
>
>       // write all the XML to a/the StringBuffe here ........
>
>       // set the style sheet source
>       javax.xml.transform.Source xslSource =
>                 new javax.xml.transform.stream.StreamSource
>                              (new
>java.net.URL("file:foo.xsl").openStream());
>
>       // Generate (instantiate) the transformer.
>       javax.xml.transform.Transformer transformer =
>                              tFactory.newTransformer(xslSource);
>
>       // Perform the transformation, sending the output to the response.
>       transformer.transform(xmlSource,
>                            new
>javax.xml.transform.stream.StreamResult(out));
>
>Bob Garvey


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message