users@jaxb.java.net

Problems generating objects from complexContent

From: Bastien Jansen <bjansen_at_excilys.com>
Date: Wed, 10 Aug 2011 23:35:51 +0200

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?