users@jaxb.java.net

Re: Nillable elements

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Tue, 03 Dec 2002 09:43:24 -0500

Marek Malowidzki wrote:
> Hi all,
>
> Is there any way to distinguish nilled element (with xsi:nil="true") from a
> missing one (i.e., not present in an instance document)?

This capability was deliberated in the JAXB expert group and the decision
was made to not expose this in the Java API. From a JavaBean property
perspective, there is nothing to really gain for a Java programmer
to have to distinguish between the XML concepts of absent from
document and xsi:nil="true". The marshal method is capable of
managing when an "xsi:nil" attribute is necessary to produce
a valid element.

The goal of JAXB was to provide a more natural and easy to use
means to access XML content. Propogating XML concepts such
as this into the Java access API did not seem to add as
much functionality as it did additional complexity.

JAXB does have a customization to test if a JAXB property is explicitly
set or not. See Section 4.5.4 isSet Property Modifier for
a description of the isSet method. This allows one to distinguish
between a property with a value that was in the document vs.
a schema specified default.

-Joe Fialli, Sun Microsystems

>
> Marek


--