I am trying to deal with interleaves (elements in a list that can appear in
any order) in jaxb, and it seems to work a little funny.
I'm working with a RELAX NG schema that looks like this:
<define name='global-protocol-settings'>
<element name='settings'>
<interleave>
<optional>
<ref name='default-type-options'/>
</optional>
<zeroOrMore>
<ref name='signal-typedef'/>
</zeroOrMore>
</interleave>
</element>
</define>
...
<define name='signal-typedef'>
<element name='typedef'>
<attribute name='name'>
<ref name='identifier'/>
</attribute>
<ref name='signal-type'/>
</element>
</define>
<define name='default-type-options'>
<element name='default-type'>
<ref name='signal-type-options'/>
</element>
</define>
which Trang converts (somewhat incorrectly perhaps; there's only supposed to
be 1 default-type-options element allowed) to this snippet of XSD:
♫
<xs:element name="settings">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="ns1:default-type"/>
<xs:element ref="ns1:typedef"/>
</xs:choice>
</xs:complexType>
</xs:element>
where "default-type" and "signal-typedef" are both elements.
The Java class for the "settings" element, that jaxb produces, has a
getDefaultTypeOrTypedef() method that returns a list of elements that are
"default-type" and "typedef". This is not what I would expect; what I'd like
is to have a getDefaultType() method and a getTypedef() method and lists of
the appropriate elements are returned. Is there something I can do to fix
this?