Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] @XmlCDATA omit CDATA when element is empty?

I kind of found a solution for this, but unfolding scenarios made my
solution invalid. :(

For those who might be reading, I was able to use the following:
@XmlCDATA
@XmlNullPolicy(nullRepresentationForXml =
XmlMarshalNullRepresentation.EMPTY_NODE, emptyNodeRepresentsNull =
true)

By setting fields to null it gives me the empty tag that I wanted
(with no CDATA wrapper).

Unfortunately, it looks like the legacy XML is generated with these rules:

1 - value = value wrapped in CDATA Tag
2 - empty string = empty node
3 - null = no node.

So I'm back in the same boat. If anyone has any ideas on how I can get
around this problem, I'd be grateful.

Thanks,
James



On Wed, Mar 21, 2012 at 11:19 AM, James Carr <james.r.carr@xxxxxxxxx> wrote:
> Hi All,
>
> I'm currently working on a project where I need to produce the same
> XML as a legacy system and one funny behavior the old system has is it
> always wraps each elment value in a CDATA tag. At first we thought
> @XmlCDATA would be exactly what we need and it is, however the old
> system omits the CDATA tag if the element value is blank.
>
> Any ideas how I could accomplish this? I keep thinking that an
> @XmlWriteTransformer might be what we need but I'm  unsure of how to
> use it.
>
>
> Thanks,
> James


Back to the top