Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [Jaxb]

Reply
Thread Tools

[Jaxb]

 
 
Stefanie Ertheld
Guest
Posts: n/a
 
      06-22-2011
Hi,

I've got an xml document like this:

<xml version="1.0 encoding="UTF-8">
<employees id="1" room="123">

<employee>
<firstname>Peter</firstname>
<lastname>Meyer</lastname>
</employee>
<employee>
<firstname>Betty</firstname>
<lastname>Boo</lastname>
</employee>

</employees>

How can that be mapped to jaxb annotations?
I've tried all sorts of things, like:

@XmlRootElement(name = "employees")
@XmlAccessorType(XmlAccessType.FIELD)
public class Employees {

@XmlAttribute(name = "id")
private String id;

@XmlAttribute(name = "room")
private String room;

@XmlElement(name = "employee")
@XmlElementWrapper(name = "employees")
private Employee[] employees;
[...]

However, this doesn't work. There is a problem with the employees
Element.
On Google I found various examples of the type:

<company>
<employees id="1" room="123">

<employee>
<firstname>Peter</firstname>
<lastname>Meyer</lastname>
</employee>
<employee>
<firstname>Betty</firstname>
<lastname>Boo</lastname>
</employee>
<employees>

</company>

This works easily - however when the document
root element is also at the same time a list,
I can't get it to work.
Any ideas?

Thanks in advance,

Stefanie
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      06-22-2011
Stefanie Ertheld <> writes:
>Subject: [Jaxb]


Brackets usually are not used around the actual subject of a
Usenet post.

We might see some funny effects, when someone from certain
web gateways responds to a post, where all of the subject is
contained in brackets. (Well, in fact, the OP was posted via
such a gateway.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments