Hi,

I have a mapping problem that I can't seem to figure out. Suppose I have the 
following XML document:

<Customer>
   <ContactInfo>
      <PhoneNumber>
         <Number>1111111111</Number>
         <Extension>1111</Extension>
         <CountryCode>111</CountryCode>
      </PhoneNumber>
      <FaxNumber>
         <Number>2222222222</Number>
         <Extension>2222</Extension>
         <CountryCode>222</CountryCode>
      </FaxNumber>
   </ContactInfo>
</Customer>

And the following Java domain objects:

public class Customer {
   private List<Phone> phoneNumbers;
}

public class Phone {
   private String type;
   private String number;
   private String extension;
   private String countryCode;
}

I want the XML document to be unmarshalled into a Customer object that has two 
Phone objects in its phoneNumbers list. The <PhoneNumber> element should 
unmarshal into a Phone object  with a type of "PHONE", and the <FaxNumber> 
element should unmarshal into another Phone object with type of "FAX". Notice 
that the Phone type value is inferred from the XML element name. The <Number>, 
<Extension> and <CountryCode> elements should bind to their respective fields 
in each Phone object.

I've tried various solutions to this, but nothing has worked so far. I suspect 
that a custom unmarshaller is required. Any advice would be appreciated.
----------------------------------------- This e-mail and any attachments may 
contain CONFIDENTIAL information, including PROTECTED HEALTH INFORMATION. If 
you are not the intended recipient, any use or disclosure of this information 
is STRICTLY PROHIBITED; you are requested to delete this e-mail and any 
attachments, notify the sender immediately, and notify the LabCorp Privacy 
Officer at privacyoffi...@labcorp.com or call (877) 23-HIPAA.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to