users@jaxb.java.net

Re: XmlType.propOrder

From: Jamie <jdennis_at_ipass.net>
Date: Tue, 19 Dec 2006 14:01:07 -0500

Kohsuke Kawaguchi wrote:
> Jamie wrote:
>> From what I can tell, this did not make it into 2.1. Can someone
>> confirm, and is it still
>> planned to be in there?
>> Jamie wrote:
>>> Can someone confirm that XmlType.propOrder for inherited attributes
>>> does not work for the RI 2.0, but does for the newly released 2.1?
>
> Can you give us bit more details? I'm not sure what you mean by
> inherited attributes.
>
Sorry, yeah, the problem I'm trying to solve is that I have a base class
which is a descriptor, it has a few attributes: name, label, key
I have many different subclasses of the descriptor, some of which don't
really add any attributes that I care about, some add an order
attribute, and some add the order and/or other attributes.

So I was hoping I could annotate my OrderedDescriptor class thusly (with
name, label and key coming from the base class):

@XmlType(propOrder={"name", "label", "order", "key"})
public class OrderedDescriptor extends Descriptor {
   @XmlElement(name="order")
   public int getOrder() {
       return myOrder;
   }
}

I found some threads in JAXB discussions that stated this is not
possible in JAXB 2.0, but that it was highly desired (without having to
mark the name, label, key attributes in the base class as transient and
have to override them in the subclasses, making alot of extra methods
which simply call the super method)... I think you actually said it was
scheduled for 2.1 (these were discussions from july 2006), so I checked
out 2.1 but it doesn't look like it made it in.

So, any info would be greatly appreciated. I have used what I consider
to be the workaround to mark transient the attributes in the base class
and override in the subclasses, but that makes me sad and made several
of my cow-orkers, um, I'm not sure what it made them, lol.