cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject Re: Streaming strings in JXTemplate
Date Thu, 12 May 2005 12:04:55 GMT
Sylvain Wallez wrote:

> Leszek Gawron wrote:
>
>> Leszek Gawron wrote:
>>
>>> 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.
>>>
>>>
>> or even better: <jx:out value="${str}" xmlize="true" strip-root="true"/>
>
>
>
> Ahem... back to another hot thread: would be good to update the docs 
> to mention these two little attributes I wasn't aware of and can be 
> soooo useful.

Agree, but we should implement them first ;)

/Daniel


Mime
View raw message