users@jaxb.java.net

Re: JAXB generating binding involving substitutionGroup head

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Wed, 20 Jun 2007 17:37:13 +0200

Hi.

I am migrating my app from JAXB 1.0 to JAXB 2.0. My schema uses
> substitutionGroup feature of XSD.
>
> A part of the schema is generating a binding that I am not understanding:
>
> <complexType name="RegistryObjectListType">
> <sequence>
> <element maxOccurs="unbounded" minOccurs="0"
> ref="tns:Identifiable"/>
> </sequence>
> </complexType>
>
> In above, Identifiable is a complexType that is a head of a
> subtitutionGroup.
>
> Based on JAXB1.0 experience with same schema I was expecting the binding
> class RegistryObjectType to generate the following methods:
>
> public List<IdentifiableType> getIdentifiable();
>
> public void setIdentifiable(List<IdentifiableType> identifiable);


...

I would appreciate some help in understanding why the generated methods
> are not the simpler ones I expected and also if there is a customization
> that will yield the simpler methods.


In your case, the field "Identifiable" may contain any element that
substitutes Identifiable. They will all be of the IdentifiableType (or its
subclasses), BUT they will have different names. Therefore, to track names
of elements, JAXB need to use JAXBElements.

Bye.
/lexi