users@jaxb.java.net

Mapping of java objects with XSD using JAXB

From: Deepa Sobhana <Deepa.Sobhana_at_ust-global.com>
Date: Wed, 4 Jun 2008 23:38:25 +0530

Hi,
 
I have a query regarding the mapping of java objects with XSD using JAXB. I have a sample XML like this

<person>
    <personname>Joe</personname>
 <age>20</age>
    <contacts>
     <contactDetails>
      <username>Smith</username>
      <address>US</address>
     </contactDetails>
     <contactDetails>
      <username>Bill</username>
      <address>Canada</address>
     </contactDetails>
    </contacts>
</person>
 
In order to easily access the list of usernames(<username>), I would like to add a new property ( List<String> userNames ) in Person class. How do I map this property with <person>/<contacts>/<username>.Is this possible using JAXB? Any help in this regard would be appreciated.
 
Thanks,
Deepa