users@jaxb.java.net

Re: Removing elements

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 10 Jan 2007 09:25:23 -0800

yca wrote:
> Hello,
>
> I have a similar question but with jaxb2 annotation (I am using jaxb2
> annotation + Spring Web Service):
>
> I have a legacy xml:
>
> <product>
> <res>
> <usprice>
> ....
> </usprice>
> </res>
> </product>
>
> And I want my Java class to be (I don't care about the <res> tag):
>
> class Product {
> protected USPrice price;
> }
>
> Can I do something like this:
>
> @XmlElement(name="res//usprice")
> protected USPrice price;
>
> Meaning specifying the node and sub-node name in the annotation directly?

Unfortunately, no. This seems to be relatively common request, so it
might make sense to allow @XmlElementWrapper on this, so that you can write:

        @XmlElementWrapper(name="res")
        @XmlElement("usprice")
        protected USPrice price;

Would you like to file an RFE for that?

... better yet, would you be interested in working with us to experiment
with this change in the RI?


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com