I tried the @XmlElementWrapper as well and got the same thing (the
anonymous complexType), which is what I was hoping to avoid. Even though
it's still valid, I agree it's not ideal, and the other tools that I'm
using seem to choke on it.
Thanks for all of your input, Wolfgang. I'll keep watching this thread,
but unless I hear otherwise, I think I'm going to keep this temporary
fix until we can upgrade to JDK 1.6. I would be interested to know what
the JAXB-RI developers think about it though.
________________________________
From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: Wednesday, September 17, 2008 8:05 AM
To: users_at_jaxb.dev.java.net
Subject: Re: Re: Re: Issue with types that refer to themselves, and
arrays
On Wed, Sep 17, 2008 at 1:13 PM, Reif, Benjamin <benjamin.reif_at_cgi.com>
wrote:
Yes, I think this would work if you wanted an unwrapped array
definition. So you just have type=Group.class in your @XmlElement, or no
type attribute in the annotation at all?
type isn't used.
We're looking for wrapped array definitions in the schema. So,
I'm curious, if you add the @XmlElementWrapper annotation, to try to
define a wrapped array, how does it come out?
Using XmlElementWrapper( name="GroupsOfXxx" )
The complexType's User and Group each have one sub-element
name="GroupsOfXxx" each of which contains an anonymous complexType with
the repeated element name="xxxGroups". IMHO, this doesn't improve
matters, at least not for marshalling and unmarshalling with JAXB: You
just have to mess with one additional layer between a User or a Group
and the List<Group>.
Does anyone have any thoughts on if this is a defect in the
JAXB-RI code, and if this fix seems reasonable?
I can't help you there. I have problems running schemagen from any of
the 2.1.x stand-alone distributions
since this appears to clash with what is in the jdk1.6 API. Adding
-Djava.endorsed.dirs=/my/jaxbhome/lib to the Java call doesn't help. Oh,
well...
Wolfgang
Ben
________________________________
From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: Wednesday, September 17, 2008 2:22 AM
To: users_at_jaxb.dev.java.net
Subject: Re: Re: Issue with types that refer to themselves, and
arrays
On Tue, Sep 16, 2008 at 9:56 PM, Reif, Benjamin
<benjamin.reif_at_cgi.com> wrote:
I think you get more re-use because I can reference use
type=" tns:GroupArray" in other elements. Otherwise it comes out looking
something like:
<xs:element form="qualified"
minOccurs="0" name="groups" nillable="true">
<xs:complexType>
<xs:sequence>
<xs:element
form="qualified" maxOccurs="unbounded" minOccurs="0" name="Group"
nillable="true" type="ns0:Group"/>
</xs:sequence>
</xs:complexType>
</xs:element>
I wouldn't like this either. - I have annotated the xxxGroups
properties the way you
wrote except for the type=Group[].class, and I get
<xs:complexType name="Group">
<xs:sequence>
<xs:element name="groupGroups" type="tns:Group" ...
minOccurs="0" maxOccurs="unbounded"/>
</..>
</...>
Since this is the way I use to write the XML schemas, I'm
perfectly happy with that.
Is this also something your "other tools" don't like?
Unfortunately we also have to use JDK 1.5, so using 1.6
isn't an option.
You'd only need the schemagen from 1.6 - that shouldn't be a
problem.
Cheers
Wolfgang