users@jersey.java.net

Re: [Jersey] entities encoding issues in the response

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 14 May 2008 19:03:25 +0200

Tatu Saloranta wrote:
> --- Paul Sandoz <Paul.Sandoz_at_Sun.COM> wrote:
>
>> Hi Arul,
>>
>> Unfortunately this is a restriction in default JAXB
>> marshaling, which
>> Jersey uses [1].
>>
>> To support this you will need to do your own
>> marshalling using say the
>> Apache XMLSerializer [2]. But in this case it is
>
> It is also possible to tweak JAXB serialization a bit
> by defining underlying xml library used for
> serialization. Calls being made by JAXB can not be
> changed, but how events are serialized can be changed.
> For example, specifying, say, Woodstox XMLStreamWriter
> as the output destination allows changing escaping
> aspects.
>
> In this particular case, it would be possible to write
> an XMLStreamWriter delegate which mostly just calls
> actual stream writer as-is, but changes calls to
> writeCharacters() to writeCData().

Can a writeCData() implementation only bracket with "<![CDATA[" and
"]]>" if escaping would otherwise be required? Or would this result in
all character data being bracketed?


> I agree in that doing this should not be necessary
> (CDATA and CHARACTERS are semantically equivalent),
> but there is so much bad legacy code around that
> sometimes it is needed.
>

Tis but a sad truth.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109