users@jaxb.java.net

RE: Re: xsi:nil

From: Vallamshettla, Anand <Anand.Vallamshettla_at_tgslc.org>
Date: Tue, 15 Feb 2005 13:54:43 -0600

---- JAXB Documentation ----
Property Binding Declarations -
Of particular interest here is the generateIsSetMethod customization,
which
causes two additional property methods, isSetQuantity and unsetQuantity,
to
be generated. These methods enable a client application to distinguish
between schema default values and values occurring explicitly within an
instance document.
--------------------

My understanding of above statement is that, isSetQuantity will return
true if <Quantity> element appears in the XML document i.e no matter
whether nil set to true or not for this element.


But when I looked up implementation for another field of type String -
all it is doing is checking for null value.

    public boolean isSetMiddleInitial() {
        return (_MiddleInitial!= null);
    }

Is this a bug or am I interpreting the document differently?

Thanks,
Anand.


-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Monday, February 14, 2005 7:56 PM
To: users_at_jaxb.dev.java.net
Subject: Re: xsi:nil

Vallamshettla, Anand wrote:
> JAXB seems to set a property value to 'null' in the following cases
>
>
>
> 1) <element xsi:nil="true"></element> is in XML doc.
>
> 2) <elemtent> tag is not in the XML doc.
>
>
>
> Is there a way in JAXB 1.0 to differentiate those 2 cases? (May be
some
> customization???)

I think this should work in 2.0 by using the JAXBElement class, but not
sure for 1.0.

You might try enabling the type substitution support, which changes the
binding somewhat, and it might allow you to do so.



-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net