Marc-

I don't know of a way to do achieve your goal in Castor, but that
doesn't mean one doesn't exist.

Looking through the Marshaller class though, I feel like you really
want to be down at the XML serializer level.  For example, when the
serializer receives a call to start element "foo" with attribute
"bar", just before it actually writes the output to a stream, you
intercept the value of bar and replace it with <![CDATA[value of
bar]]>.  Anything higher up the chain I'm afraid will end up getting
escaped by the serializer.  Sounds like a job for AspectJ if I ever
heard one :)  Sorry I can't be of more help.  Your post processing
might be the easiest way to go.

Stephen


On 3/21/06, Marc Respass <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm new to the list and just started using Castor. I'm impressed so
> far but I've run into a problem. The party who has defined the XML
> document demands that all values be wrapped in CDATA. Right now, I am
> marshalling the object with Castor and then hacking the document by
> calling getElementsByTagName(), pulling the value, creating a CDATA
> section, removing the element's child, and appending the new CDATA
> section. It would be cool if I could get the value wrapped in CDATA
> automatically during the marshalling. I tried writing a
> GeneralizedFieldHandler that would wrap the value like
>
> value = "<![CDATA[" + value + "]]>";
>
> but that is so wrong and the first "<" gets escaped. I've look around
> and tried lots of different things but I have been entirely
> unsuccessful. Can anyone point me in the right direction to do this?
> Is it possible or is my hack not really a hack so I should change my
> method name from hackDocument() to fixUpDocument()? :)
>
> Thanks a lot
> Marc
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>

Reply via email to