users@jaxb.java.net

no code is generated to indicate a doc contains an optional element ?

From: <spambin_at_PERIGON.COM>
Date: Tue, 24 Dec 2002 13:34:27 -0700

Hi,

I was wondering how the generated java code communicates the presence
or non-presence of an optional element. In the sample application
I changed the definition for a purchase order item (po.xsd) as follows ->

please note the optional element "flex".


<xsd:complexType name="Items">
  <xsd:sequence>
    <xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
      <xsd:complexType>
        <xsd:sequence>
         <xsd:element name="productName" type="xsd:string"/>
         <xsd:element name="quantity">
           <xsd:simpleType>
             <xsd:restriction base="xsd:positiveInteger">
               <xsd:maxExclusive value="100"/>
             </xsd:restriction>
           </xsd:simpleType>
         </xsd:element>
         <xsd:element name="USPrice" type="xsd:decimal"/>
         <xsd:element ref="comment" minOccurs="0"/>
         <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>

******** <xsd:element name="flex" type="xsd:int" minOccurs="0"/>

        </xsd:sequence>
        <xsd:attribute name="partNum" type="SKU" use="required"/>
      </xsd:complexType>
    </xsd:element>
  </xsd:sequence>
</xsd:complexType>


the generated java code (in primer/po/Items.java gave me a
  setFlex and a getFlex method... but no "out of band" notification
  that would indicate there was no value at all for this element.

Castor generates something like boolean hasFlex().

It would be nice to have something like that... but even better would
be information that is accessible from a java bean property something like:

   boolean getFlexIsSet()


thanks
chris