Hi,
I am using XmlElementRef on an attribute which uses a generics List.
I have a fairly complex hierarchy of classes and the base class is the
class listed in the generic for the attribute, e.g.
@XmlElementRef
List<A> listOfA = new ArrayList<A>() ;
In most cases this works fine. The issue I am having is that for two of the
sub-classes (which are leaf classes in my class hierarchy), JAXB is generating XML
elements corresponding to their parent class. In particular, I have three classes
D, E, F which are all subclasses of class C. (C is a sub-class of B, which in turn
is a sub-class of A.) If I have objects of all three types, JAXB will marshal out an
element of type D for the D objects but elements of type C for E and F objects.
I have generated my XML schema using schemagen.sh which comes with the JAXB distribution
and the part of the schema corresponding to the list is a choice element containing
elements for all the sub-classes of A. All classes in the hierarchy are annotated with
XmlRootElement. I am observing this behavior with both JAXB 2.1.5 and 2.1.6.
Any ideas ?
Thanks.