users@jaxb.java.net

Re: Problems generating objects from complexContent

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 11 Aug 2011 12:19:21 +0200

The base class PartyDescriptor has "naughty children" so that its content
all has to go into a catch-all List<JAXBElement>.

See the javadoc in PartyDescriptor for a description of what is bad and for
a tip of how to fix it.

-W


On 10 August 2011 23:35, Bastien Jansen <bjansen_at_excilys.com> wrote:

> Hi,
>
> I'm trying to generate Java objects from the DDEX XSD (
> http://ddex.net/xml/20081015/ddexC.xsd) using JAXB. The problem is that
> the generated objects are missing java attributes.
> For example, this element definition:
>
> <xs:complexType name="DisplayArtist">
> <xs:complexContent>
> <xs:extension base="ddexC:PartyDescriptor">
> <xs:sequence>
> <xs:element name="ArtistRole" type="ddexC:ArtistRole"
> minOccurs="0"
> maxOccurs="unbounded">
> </xs:element>
> </xs:sequence>
> <xs:attribute name="SequenceNumber" type="xs:integer"
> use="optional">
> </xs:attribute>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> is translated into
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "DisplayArtist")
> public class DisplayArtist
> extends PartyDescriptor
> {
>
> @XmlAttribute(name = "SequenceNumber")
> protected BigInteger sequenceNumber;
>
> public BigInteger getSequenceNumber() {
> return sequenceNumber;
> }
>
> public void setSequenceNumber(BigInteger value) {
> this.sequenceNumber = value;
> }
>
> }
>
> DisplayArtist.java is missing a List<ArtistRole>. I don't know why it is
> not generated. I noticed that if if remove the complexContent and extension
> tags, I get what I want (but I loose the inheritance...).
>
> Does anyone know why this happens?
>