cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Neu" <peter....@gmx.net>
Subject AW: AW: AW: How to use cocoon servlet only for rendering documents?
Date Thu, 16 Feb 2006 10:36:36 GMT
Hello,

thanks for the advice this works perfectly! As suggested only adding
streaming generator suffices to do it.

Just one last question to end the subject: When I generate the xml in my
non-cocoon apps. It looks somehow like this:

PrintWriter out = response.getWriter();
StreamResult streamResult = new StreamResult(out);
SAXTransformerFactory tf = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
TransformerHandler hd = tf.newTransformerHandler();
Transformer serializer = hd.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
hd.setResult(streamResult);
AttributesImpl atts = new AttributesImpl();
hd.startDocument();
hd.startElement("", "", "Document", atts);
hd.characters("Hello Document".toCharArray(), 0, "Hello Document".length());
atts.clear();
hd.endElement("", "", "Document");
hd.endDocument();

Now in order to pass it to cocoon via the commons httpclient I need it to
be a File Input Stream e.g. a file object. 

post.setRequestEntity(new InputStreamRequestEntity(
                new FileInputStream(input), input.length()));

But this is not a good idea because it would be then saved locally and would
create some overhead. What I need to do is keep it in memory to pass the sax
pipeline to the post call. How could I do this?

Cheers,
Pete




-----Ursprüngliche Nachricht-----
Von: Bertrand Delacretaz [mailto:bdelacretaz@apache.org] 
Gesendet: Mittwoch, 15. Februar 2006 17:58
An: dev@cocoon.apache.org
Betreff: Re: AW: AW: How to use cocoon servlet only for rendering documents?

Le 15 févr. 06, à 17:49, Peter Hunsberger a écrit :

> ...Won't the request generator also
> do the trick at this point?  Or will it muck the embedded XML?..

The RequestGenerator should work if input values are passed as  
parameters (although I've never tried it with XML fragments as  
parameters).

The StreamGenerator also gives access to the POST body (depending on  
the mimetype of the request, see  
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/generation/ 
StreamGenerator.html)

-Bertrand



Mime
View raw message