users@jaxb.java.net

Re: Java inheritance

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Tue, 11 Jul 2006 07:31:32 +1000

Hi David,

The second post was mine, and I should retract the opening of it as it
is not a bug at all, rather it is an accurate reflection of xml schema
inheritance.

In xml schema, inheritance can only append elements, and so that is
what jaxb does. what you can do, is something like this:

@XmlRootElement
class SuperClass
{
  String foo;
}

@XmlRootElement
class SubClass
{
  String bar;
}

this will then (I think) give you:

<SubClass>
  <foo> ... </foo>
  <bar> ... </bar>
</SubClass>

Unfortunately you wont be able to swap the order of foo and bar, which
I gather is what you'd like to do.

Does this help you? Please post some code and also some desired
output and I'll see if I can help more.

cheers
dim


On 7/11/06, David Blevins <david.blevins_at_visi.com> wrote:
> These two posts seem to detail quite nicely what I'm facing.
>
> https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=4111
> https://jaxb.dev.java.net/servlets/ReadMsg?listName=users&msgNo=4252
>
> In short, I've generated a JAXB2 annotated Java tree from the Java EE
> 5 ejb-jar xsd and would now like to introduce a superclass
> (EnterpriseBean) for EntityBeanType, MessageDrivenBeanType and
> SessionBeanType as 80% of their properties are the same.
>
> I'm finding this to be an impossible task as declaring the propOrder
> in the subclass results in the "..._at_XmlType.propOrder... no such
> property exists" exception and declaring a @XmlType.propOrder in the
> superclass gives me the wrong order in xml.
>
> What will it take to support this feature? I understand there may be
> issues, but I'm almost certain i'd prefer those issues over this one.
>
> Thanks,
> David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>