users@jaxb.java.net

Re: wrapping collections by using adapters

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Thu, 23 Mar 2006 09:13:54 +1100

Hi Sekhar,

Sorry for the delay - thanks for that, works a treat.

cheers
dim

On 3/21/06, Sekhar Vajjhala <Sekhar.Vajjhala_at_sun.com> wrote:
> Hi Dmitri,
>
> Dmitri Colebatch wrote:
>
> Hi Sekhar,

Firstly, thanks for your very helpful response.

On 3/18/06,
> Sekhar Vajjhala <Sekhar.Vajjhala_at_sun.com> wrote:

> https://jaxb.dev.java.net/nonav/jaxb20-pfd/api/javax/xml/bind/annotation/XmlElementWrapper.html

@XmlAccessorType(FIELD)
@XmlRootElement
public
> class Foo
{
 @XmlElementWrapper(name="bars")
 Set<Bar> bar;
}

> That very nearly does what I need, and in my case I think it'll do,
but I'll
> ask the following in case you have another answer!

My problem is that the
> following xml is valid:


<foo>
 <bars>
 <bar>
 <name>abc</name>
> <price>123</price>
 </bar>
 <bartotal>
 <price>123</price>
 </bartotal>
> </bars>
</foo>

Of course bartotal/price is just the sum of the bar/price
> elements and
I don't care for it as I know how to do maths (o: However I do
> need
to ensure that I can handle what are valid documents. My
> current
thoughts are that I'll wrap my parse in some xslt to strip
> the
bartotal elements that I don't want and then do your suggestion,
however
> I wanted to check with you first to see if you had any other
ideas in light
> of the above.
>
> You don't need do anything special to strip out the bartotal
> element on an unmarshal i.e. if you unmarshal the above
> XML instance using the code shown above the XML
> instance, bartotal element will be ingored.
>
> Sekhar
>
>
cheers
dim

---------------------------------------------------------------------
To
> unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>