users@jaxb.java.net

Re: Getting JAXB to instanciate your subclasses

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Fri, 06 Jun 2003 17:23:11 -0400

Pratik Datta wrote:
> Hi Ryan
>
>
>> We are actually in the process of publishing a FAQ that outlines almost the same
>> identical procedure. It should hit the web early next week...
>
>
> I really like this double xjc hack. Has this been published to a FAQ ?
>

The FAQ was published several weeks ago:

http://java.sun.com/xml/jaxb/extendingJaxbGeneratedClasses.html

But please keep in mind that you only need the double-xjc step for
JAXB RI 1.0 - the new 1.0.1 version of the JAXB RI works correctly
with a single execution of xjc.

If you're using JAXB RI 1.0.1, the you only need to read the top
half of the FAQ and can skip the "JAXB RI FCS 1.0 Workaround" section.

>
> Will the future version have JAXB spec allow specifying a superclass for the
> implementation class? I am a little wary of using of using the vendor extension as it
> might go away in the future.
>

Our intention is to add this feature to a future version of the JAXB
specification. However, since this spec is developed under the JCP,
it is possible that other companies in the expert group may change
it's functionality or prevent it from going in the spec at all. It
isn't completely under our control.

>
> I am facing a small problem with the double xjc. If I have a named complexType "foo"
> which contains an element "bar" of an anonymous complexType, then even if I specify a
> custom implementation class for "foo", jaxb will still generate an implementation class
> for "foo", and all that will have is a inner class for "bar". This class will overwrite
> the class that I generated the first time.
>
> Obviously if I use named complexTypes instead of anonymous ones, the problem goes away.
>

Which version of JAXB are you using? Can you send me a small schema
fragment to work with?

Thanks,

--Ryan

>
> Pratik
>