users@jaxb.java.net

Re: Generated classes extend

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Mon, 24 Mar 2003 10:54:50 -0500

Sriram Thyagarajan wrote:
> Is there a way to specify the generated class to extend/implement another
> class not specified in the schema ?
>

Sriram,

Yes and no.

> e.g.
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> <xsd:element name="XmlInterfaceRecord" type="XmlInterfaceRecordType"/>
>
> <xsd:complexType name="XmlInterfaceRecordType">
> <xsd:sequence>
> <xsd:element name="AccidentHeader" type ="AccidentHeader"
> minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
>
> generates ....
>
> public interface XmlInterfaceRecord
> extends javax.xml.bind.Element, abc.XmlInterfaceRecordType
> {
> }
>
>
> and what I am looking for is the generated class extend
> xyz.GenericXmlInterfaceRecord (defined in a different package and not
> defined in the XML Schema)
>
> public interface XmlInterfaceRecord
> extends javax.xml.bind.Element, abc.XmlInterfaceRecordType,
> xyz.GenericXmlInterfaceRecord
> {
> }
>

JAXB implementations, including the RI, are not allowed to alter the
signatures of the generated interfaces like you've shown above. Every
JAXB provider must generate the same set of interfaces.

On the other hand, we are free to modify the generated implementation
classes. We provide a <jaxb:superClass> customization that allows you
to specify a common base type for all of the generated impl classes[1],
but that might not suit your needs. We are also working on a way of
allowing you to subclass the generated impl classes - stay tuned.

Thanks,

--Ryan

[1] http://java.sun.com/webservices/docs/1.1/jaxb-1.0/vendor.html#superclass

>
> Thanks
>