Thanks Tatu and Paul for the great suggestions.
I will be trying to implement as per your below suggestion. In your code
excerpt, you are referring to mImpl. Is this an instance of custom
XMLStreamWriter?
Please clarify.
Cheers,
Arul
Tatu Saloranta wrote:
> --- Paul Sandoz <Paul.Sandoz_at_Sun.COM> wrote:
>
>
>> Tatu Saloranta wrote:
>>
>>> --- Paul Sandoz <Paul.Sandoz_at_Sun.COM> wrote:
>>>
> ...
>
>>> 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?
>>
>
> The way I think it would be done, the custom wrapper
> implementation (class that implements XMLStreamWriter
> by acting as a proxy to underlying concrete stream
> writer impl) could definitely redirect only some calls
> (or even split a single call to multiple different
> ones).
> Something like:
>
> ---
> public class MyStreamWriter implements
> XMLStreamWriter()
> {
> // ...
> public void writeCharacters(String text) // throws...
> {
> if (shouldUseCData(text)) {
> mImpl.writeCData(text);
> } else {
> mImpl.writeCharacters(text);
> }
> }
> // other methods just pass to mImpl without checks
> }
>
> XMLStreamWriter swImpl =
> XMLOutputFactory.createXMLStreamWriter(...);
> XMLStreamWriter sw = new MyStreamWriter(swImpl);
> marshaller.marshal(myObject, sw);
>
> ---
>
> The question, then, is if and how to configure Jersey
> to use that stream writer impl. It would even be
> possible to create one's own XMLOutputFactory to
> produce such wrapped writers (and use system property
> to make JDK use that).
> But hopefully that would not be necessary.
>
> -+ Tatu +-
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
> ________________________________
> Scanned by MessageLabs for Flux
> ________________________________
>