users@jaxb.java.net

Re: Question about primitive types API: determing if an element is set or not?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 30 May 2003 12:09:59 -0700

Han Ming Ong <hanming_at_mac.com> wrote:
> My problem is that my users want me to tell them if in the original
> XML document, the element <read-only> is actually present or not. For
> Java, isReadOnly() will return 'false' if not initialized, hence it
> becomes ambiguous if the actually value is 'false' or just plain
> missing.

Try:

    <xsd:annotation><xsd:appinfo>
      <jaxb:property generateIsSetMethod="true"/>
    </xsd:appinfo></xsd:annotation>

In you case, it would be:

    <xs:element minOccurs="0" ref="read-only">
      <xsd:annotation><xsd:appinfo>
        <jaxb:property generateIsSetMethod="true"/>
      </xsd:appinfo></xsd:annotation>
    </xs:element>

Or the equivalent external customization.

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com