Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB Help

 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you will get a Car object and a Wheel object ... and like it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic