users@jaxb.java.net

How do I separate the <xsd:choice/> sub elements into individual list properties?

From: Jarrod Roberson <jarrod_at_vertigrated.com>
Date: Fri, 12 Aug 2011 09:02:15 -0400

I posed this question on stackoverflow.com, I am posting a link to it for
those of you that use it.

http://stackoverflow.com/questions/7033600/how-do-i-separate-the-xsdchoice-sub-elements-into-individual-collection-prope

<xsd:element name="navmap">
  <xsd:complexType>
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element ref="navitem"/>
      <xsd:element ref="debug"/>
    </xsd:choice>
    <xsd:attribute name="focus" type="xsd:string" use="optional"/>
  </xsd:complexType>
</xsd:element>

 by default generates this

@XmlElements({
        @XmlElement(name = "navitem", type = Navitem.class),
        @XmlElement(name = "debug", type = Debug.class)
    })
    protected List<Object> navitemOrDebug;


and I want something like this

@XmlElements({
        @XmlElement(name = "navitem", type = Navitem.class)
    })
    protected List<Navitem> navitems;

@XmlElements({
        @XmlElement(name = "debug", type = Debug.class)
    })
    protected List<Debug> debugs;

How do I get the desired output?