• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAXB Help

 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you will get a Car object and a Wheel object ... and like it
reply
    Bookmark Topic Watch Topic
  • New Topic