users@jaxb.java.net

Re: wrapping collections by using adapters

From: Sekhar Vajjhala <Sekhar.Vajjhala_at_Sun.COM>
Date: Mon, 20 Mar 2006 09:24:31 -0500

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
>
>
>