Two Laptop Bag*
The moose likes XML and Related Technologies and the fly likes JAXB Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB Help" Watch "JAXB Help" New topic
Author

JAXB Help

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hi,
I have an XML such as:



As you can see Wheel has two elements colour and size. In JAXB, to represent this I could have a JAXB Car class and a JAXB Wheel class.
But I think this is overkill. I would like to represent this structure as just one JAXB class: Car.

Is there any way to do this?

Also, just say the in Java the only element I am in interested in the Wheel is the colour, it is possible to just get this element into a JAXB Car class anyway?

Thanks


Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Aside, you could write your own code to read the XML-based document and create whatever objects you want without using the JAXB API.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Jimmy Clark wrote:Aside, you could write your own code to read the XML-based document and create whatever objects you want without using the JAXB API.

Correct. If I was only looking for one attribute, I do that and use DOM /XPATH.

I want to avoid writing marshalling code and use JAXB as much as I can here.

Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
So you will get a Car object and a Wheel object ... and like it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB Help