users@jaxb.java.net

Re: wrapping collections by using adapters

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Sat, 18 Mar 2006 22:36:58 +1100

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.

cheers
dim