cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <>
Subject Re: Streaming strings in JXTemplate
Date Thu, 12 May 2005 11:14:03 GMT
Reinhard Poetz wrote:
> Can it be that difficult to stream a string as SAX events in JXTemplate, 
> or did I overlook a simpler solution?
>  - implement your own streamer object with a toSAX method
>  - pass a streamer object to JXTemplate
>  - assign this object to a variable
>  - call the toSAX method and pass the content handler and the
>    string that should be streamed to it
> ----
> <jx:set var="streamer" value="${request.getAttribute('streamer')}"/>       
> <p>#{toSAX($streamer, '&lt;b&gt;blah&lt;/b&gt;', $cocoon/consumer)}"/></p>
> ----
> the toSAX method of the streamer
> public void toSAX(String content, ContentHandler handler) throws 
> SAXException {
>   (new StringXMLizable(content)).toSAX(new IncludeXMLConsumer(handler));
> }
> ----
> Can't we do this better?

 From a quick check of the code it seem like jx:out is XMLizable aware, 
so you should be able to use jx:out on your XMLizable object. If it 
doesn't work, it is a bug that we should fix.

If you want to make it even simpler we could either have another 
instruction that parses strings to SAX, or have some attribute on jx:out 
for parsing the argument.


View raw message