users@jaxb.java.net

_at_XmlElementWrapper - question regarding naming the child elements

From: Alex Bleasdale <rhodlite78_at_yahoo.co.uk>
Date: Thu, 12 Nov 2009 16:17:08 -0800 (PST)

Hi,

Hoping someone can help. I'm using JAXB to generate XML based on some
webservices I'm writing using Jersey. I have a Result bean, which generates
a wrapper called "hits" and then proceeds to write out XML elements for each
of the items in the list; which is great.

However, the issue I'm having is each child element contains the same name
as the wrapper, like this:

<results>
<hits>
  <hits id="12345" count="39"/>
</hits>
</results>

I'd really like all of the items to have the name "hit" instead, like so:

<hits>
  <hit id="12345" count="39"/>
</hits>

I was really hoping I could specify the name of the "root element" at the
top of the child class (in this case TrackerHit), so the result bean has a
section that looks like this:

@XmlElementWrapper(name = "hits")
        public List<TrackerHit> getHits() {
                return hits;
}

And here's what I've got for the TrackerHit

@XmlRootElement(name = "hit")
public class TrackerHit {
(...)
}

Anyone know how I can "label" child elements in a situation like this?

Thanks in advance,
Alex
-- 
View this message in context: http://old.nabble.com/%40XmlElementWrapper---question-regarding-naming-the-child-elements-tp26328516p26328516.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.