Java Mailing List Archive

http://www.junlu.com/

Home » user.castor »

[castor-user] Question about mapping

Sam-1234

2010-02-10

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi-
I need some advice regarding mapping.
Below is my demo xml

<response>
 <life>
   <liferesponse>
     <id>12</id>
     <Parent>
       <Partner>
         <person>
           <firstname>A</firstname>
         </person>
         <address>
           <line1>Addres 1</line1>
         </address>
       </Partner>
       <Partner>
         <person>
           <firstname>B</firstname>
         </person>
         <address>
           <line1>Add 1</line1>
         </address>
       </Partner>
     </Parent>
   </liferesponse>
 </life>
</response>

My aim is to get a list of 'Partner' after unmarshalling.

<mapping>
<class name="com.Output">
 <map to xml="Parent" />
<field name="results" type="com.PartnerResult" collections="arraylist">
 <bind-xml name="Partner" node="element" />
</field>
<class name="com.PartnerResult">
<map to xml="Partner" />
<field name="firstname" type="string">
 <bind-xml name="firstname" node="element" location="person" />
</class>
</mapping>

Can I map to 'Parent' directly into output without traversing thro'
response/life/liferesponse nodes ?
I did tried below
<class name="com.Output">
 <map to xml="response" />
<field name="results" type="com.PartnerResult" collections="arraylist">
 <bind-xml name="Partner" node="element" location="life/liferesponse/Parent"
/>
with this, I am able to get a list size as 2 as per above example but value
of 'firstname' is null.
I would assume as 'Output' is mapped to root node 'response' and location
for arraylist is set as /Parent,
it may print value of first name.

Am I missing anything here?

Please advice.

Thanks,
Sam
--
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 junlu.com - Jax Systems, LLC, U.S.A.