views:

133

answers:

1

Hi,

how do i prevent schemagen from adding the super-class to the schema?

I have tried using XMLTransient on the super-class, and on its fields but they still show up in the schema .

for example :

@XmlTransient
public class Asset {

   @XmlTransient
   public Long ID;
}

public class Movie extends Asset {

}

creates this schema :

<xs:complexType name="asset">
<xs:sequence>
<xs:element name="ID" type="xs:long" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="movie">
<xs:complexContent>
<xs:extension base="asset">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

the schema that i would like to see is :

<xs:complexType name="movie">
<xs:complexContent>
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
A: 

You have found the answer yourself. If you add the @XMLTransient annotation to a field, it will be omitted by JAXB Java-to-schema generation. This is stated here XMLTransient documentation.

If your schemagen tool you are using doesn't do this, than it has a fault in its implementation.

Leni Kirilov