Daniel Fagerstrom wrote:
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.
<jx:out value="${str}" xmlize="true"/> ? Almost one liner.. some users also asked about it long time ago.


-- Leszek Gawron [EMAIL PROTECTED] IT Manager MobileBox sp. z o.o. +48 (61) 855 06 67 http://www.mobilebox.pl mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65

Reply via email to