tags:

views:

440

answers:

1

Using JAXB (2) is it possible to ensure that null values are not marshalled as () empty elements. For instance

@XmlRootElement(name = "root")
public class Root {
    @XmlElement(name = "name")
    protected String name;
}

Currently if name is null then I am marshalling

<root>
  <name/>
</root>

I would like to produce

<root>
</root>

instead.

+1  A: 

i think u have missed something.. as u marshal it ,the string u are passing must not be null as with string null is also an string.. so in my opinion u must pass empty string rather than null.

Mrityunjay