users@jaxb.java.net

xsd:choice and jaxb generated code

From: Nicolas Pujol <nicolaspujol_at_yahoo.com>
Date: Thu, 24 Mar 2005 17:09:52 -0800 (PST)

Hi,

 I was wondering if there was a way (either via schema
or jaxb ) to handle the case where all the element
under an xsd:choice are of the same type. I am asking
this because the code that is currently generated is
generic and assumes that these elements are of
different types and consequently has to create
additional code which is cumbersome to work with if it
turns out the elements share the same parent type.

Let's say i have this

<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="useractivity" type="t_useractivity"
minOccurs="0"/>
<xs:element name="wsactivity" type="t_wsactivity"
minOccurs="0"/>
</xs:choice>

and both t_useractivity and t_wsactivity actually are
types that inherit from a common type named t_activity
e.g:

<xs:complexType name="t_useractivity">
<xs:complexContent>
<xs:extension base="t_activity"/>
</xs:complexContent>
</xs:complexType>
and
<xs:complexType name="t_wsactivity">
<xs:complexContent>
<xs:extension base="t_activity"/>
</xs:complexContent>
</xs:complexType>




If that is case, then it would suffice for the
generated api to return a list of "t_activity"
elements and not ,as it currently does, create
additional interfaces for each of the elements that
help identify the various types.

I hope i am describing the problem well.....

thanks





__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com