users@jaxb.java.net

Re: How JAXB Generates Choices

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Thu, 09 Jan 2003 10:08:32 -0800

> the generated code creates get and set methods for each of the sub
> elements. I think that what's missing, and very important is a way to
> find out which sub-object is the choice.

Indeed this was an unimplemented feature in beta. We will have that in
the FCS release.

Also, another approach that works with beta is to add a property
customization so that all four properties are aggregated into one
property.

<xs:complexType name="BIND-dmo1">
  <xs:annotaion><xs:appinfo>
    <jaxb:property name="membrane"/>
  </xs:appinfo></xs:annotation>
  <xs:choice>
    <xs:element ref="BIND-dmo_general" />
    <xs:element name="BIND-dmo_outer-membrane"
type="BIND-dmo_outer-membrane1" />
    <xs:element name="BIND-dmo_inner-membrane"
type="BIND-dmo_inner-membrane1" />
    <xs:element name="BIND-dmo_general-membrane"
type="BIND-dmo_general-membrane1" />
  </xs:choice>
</xs:complexType>

I think this should produce something like

public interface BINDDmo1 {
    Object getMembrane();
    void setMembrane(Object o);

    public interface BINDDmoGeneral { ... }
    public interface BINDDmoOuterMembrane { ... }
    public interface BINDDmoInnerMembrane { ... }
    ...
}

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