I'm not aware of any XML data binding framework that would allow you
to control whether something is serialized as a text node or a CDATA
section. This is by design, because the difference between a text node
and a CDATA section is only syntactic, but has no semantic meaning.
This implies that any system that processes a CDATA section
differently from an equivalent text node should be considered as
broken. At least that is the what most people in the industry believe.

Andreas

On Mon, Dec 7, 2009 at 21:49, Ramya K Grama <[email protected]> wrote:
> Thanks for the quick reply!
> I am using XMLBeans 2.3.0.  I am not using AXIOM APIs directly to
> create the response elements.
> Hence, I am not using OMText directly.
> From the XMLBean api, I am able to use only setText and have not found
> a way to passin the CDATA type (neither in an overloaded setText nor
> in a setType).
>
> Could you please share a code snippet showing how to pass the CDATA
> type using XMLBeans or how to get the OMText node from the XMLBean
> object.
> With XMLBeans I have <operationName>Document object. How do I get an
> OMText out of it to be able to set the Type.
>
>
>
>
> On Mon, Dec 7, 2009 at 3:39 PM, Andreas Veithen
> <[email protected]> wrote:
>> XMLInputFactory.properties can be used to preserve CDATA sections when
>> using Axiom to _parse_ an XML document (By default CDATA sections are
>> transformed to text nodes and coalesced with adjacent text nodes). On
>> the other hand, creating CDATA sections in output documents is
>> something that Axiom has always supported.
>>
>> Probably what you are doing is to create an OMText node with type TEXT
>> and content "<![CDATA[ROSEANNA]]>". In the output document, this gets
>> of course escaped. What you need to do instead is to create an OMText
>> node with type CDATA and content "ROSEANNA".
>>
>> Andreas
>>
>> On Mon, Dec 7, 2009 at 20:45, Ramya K Grama <[email protected]> wrote:
>>> Hello,
>>> We have been having issues with CDATA not being preserved by Axis2.
>>> In the response xml, the '<' are escaped to '&lt;'
>>> So instead of <someTagName><![CDATA[ROSEANNA]]></someTagName> we get
>>> <someTagName>&lt;![CDATA[ROSEANNA]]&gt;</someTagName> in the response.
>>>
>>> Reading this
>>> http://people.apache.org/~veithen/synapse/faq.html#cdata
>>> suggestion, we tried creating XMLInputFactory.properties file
>>> containing this single line - javax.xml.stream.isCoalescing=false
>>>  and placed the file under WEB-INF/classes and retried, again the same 
>>> result.
>>>
>>> We are using Axis21.4, XMLBeans 2.3.0, Tomcat 6.
>>>
>>> The other idea was to programatically replace the escape characters
>>> using regular expressions - which I think is really not needed.
>>>
>>> Any help is highly appreciated.
>>>
>>
>

Reply via email to