Hi,
I'm trying to generate JAXB classes (I'm using CXF 2.3.1) from
following schema:
<complexType name="RoleList">
<sequence>
<element ref="cdm:role" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
</complexType>
<element name="role" type="cdm:AbstractRole" abstract="true"
nillable="true"/>
<complexType name="AbstractRole" abstract="true">
<complexContent>
<extension base="cdm:AbstractEntity">
<sequence>
<element name="externalID"
type="string" nillable="true" minOccurs="0"/>
<element name="status" type="string"
nillable="true" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
JAXB generates:
@XmlElementRef(name = "role", namespace = "
http://test", type =
JAXBElement.class)
protected List<JAXBElement<? extends AbstractRole>> role;
The problem is that I'm not able to change the existing schema. If I
change the schema like this:
<complexType name="RoleList">
<sequence>
<element name="role" minOccurs="0"
maxOccurs="unbounded" type="cdm:AbstractRole" abstract="true"
nillable="true"/>
</sequence>
</complexType>
JAXB generates exactly what I want, but the problem is that I'm not
able to change the schema.
Could you please advise me about the binding that I have to use in
order JAXB to generate:
protected List<AbstractRole> role;
instead of
protected List<JAXBElement<? extends AbstractRole>> role;
My binding file looks like:
<jaxb:bindings version="2.0"
xmlns:jaxb="
http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="
http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings>
<xjc:generateElementProperty>false</xjc:generateElementProperty>
</jaxb:globalBindings>
<jaxb:bindings scd="x-schema::tns"
xmlns:tns="
http://www.w3.org/2001/XMLSchema">
<jaxb:schemaBindings>
<jaxb:package name="com.test" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings scd="x-schema::tns" xmlns:tns="
http://test">
<jaxb:schemaBindings>
<jaxb:package name="com.test" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
Thanks.