• 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

Unmarshall a Choice element

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Below is a example schema with a choice element.




The JaxB creates a class with name of "Sports"

The Sports class holds 3 members -

I have an xml string which is a representation of a Sports class which hold information of Name, Location Address all confiugred,

The interesting one is Location which is a choice, so is configured to either "home" or "away" element details.

Having a xml string representation of a Sports class, I apply the Unmarshaller.unmarshall() on the xml string to
obtain a populated Sports instance from the xml string.

When unmarshall() is invoked , passing in the xml String, a Sports instance is created with the Name and Address field beng populated in the new instance.
BUT the Location is not configured and remains null.

Any suggestions alternarive approach that will unmarshall and xml string ( which has Location choice configured ) successfully to a Sport instance.

Many thanks for your help

Pete
 
Pete Palmer
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It appears my xml string was not complete and hence why I was obtaining a null for the Location field.

So issue is resolved.

Pete.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic