cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Poetz <reinh...@apache.org>
Subject Re: XML Fragements in widgets
Date Thu, 12 May 2005 05:57:37 GMT
Sylvain Wallez wrote:
> Reinhard Poetz wrote:
> 
>> Sylvain Wallez wrote:
>>
>>> Reinhard Poetz wrote:
>>>
>>>>
>>>> I have the need for a widget that contains XML fragments. Those 
>>>> fragements should also be streamed as XML and not as strings. How 
>>>> can I achieve this? My first (and only) idea is implementing a new 
>>>> widget type (XMLWidget). Or are there better solutions?
>>>
>>>
>>>
>>>
>>> I've had for months an unfinished and therefore uncommitted XML 
>>> datatype on my hard disk and the associated convertors. Want to 
>>> finish them?
>>
>>
>>
>> Sounds interesting but I'm not sure if this solves my problem. If I 
>> have a widget that has the value "<someXML>bla</someXML>" I need it 
>> serialized as
>>
>> <fi:field>
>>   <fi:value>
>>     <someXML>bla</someXML>
>>   </fi:value>
>> </fi:field>
>>
>> and not as
>>
>> <fi:field>
>>   <fi:value>
>>     &lt;someXML&gt;bla&lt;/someXML&gt;
>>   </fi:value>
>> </fi:field>
>>
>> After looking at Field.generateSAXFragement() (line 405) I don't think 
>> that a special datatype or a convertor can help here as only the 
>> string representation of the value is passed to the content handler:
>>
>> contentHandler.characters(stringValue.toCharArray(), 0, 
>> stringValue.length());
>>
>> Therefore my conclusion that I need a special XML widget that can 
>> produce more than character events, right?
> 
> 
> 
> Right. Unfortunate but right.
> 
> What's your use case? If it's of general interest, we could add some 
> "xml aware" convertors that could produce a SAX stream additionally to a 
> string:
> 
> interface XMLConvertor extends Convertor {
>    convertToXML(Object value, Locale locale, FormatCache cache, 
> ContentHandler handler)
> }


My usecase is that my backend provides many text snippets and they have to be 
mixed in between widgets. As these snippets are independant of particular 
widgets I can't use fd:hint. On the other hand these snippets relate to the 
state of the forms application and it *could* be more convenient for the 
programmer to deal with the snippets within the forms framework (--> event 
handling).

I'm going to implement it by putting the snippets into separate objects for the 
first. If this becomes clumsy I will fall back to the XMLConvertor idea.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------


Mime
View raw message