You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Reinhard Poetz <re...@apache.org> on 2005/05/10 17:31:30 UTC
XML Fragements in widgets
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?
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
Re: XML Fragements in widgets
Posted by Reinhard Poetz <re...@apache.org>.
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>
>> <someXML>bla</someXML>
>> </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
--------------------------------------------------------------------
Re: XML Fragements in widgets
Posted by Sylvain Wallez <sy...@apache.org>.
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>
> <someXML>bla</someXML>
> </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)
}
Sylvain
--
Sylvain Wallez Anyware Technologies
http://apache.org/~sylvain http://anyware-tech.com
Apache Software Foundation Member Research & Technology Director
Re: XML Fragements in widgets
Posted by Reinhard Poetz <re...@apache.org>.
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>
<someXML>bla</someXML>
</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?
--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}
web(log): http://www.poetz.cc
--------------------------------------------------------------------
Re: XML Fragements in widgets
Posted by Sylvain Wallez <sy...@apache.org>.
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?
Sylvain
--
Sylvain Wallez Anyware Technologies
http://apache.org/~sylvain http://anyware-tech.com
Apache Software Foundation Member Research & Technology Director