You are welcome.

Cheers
Werner

On 11.02.2010 16:05, Sam-1234 wrote:

===
Yes, it makes sense now !.
Thanks for your reply Werner.


Werner Guttmann-6 wrote:

Hi,

in your case, I'd have a Java class Partner that should be bound to an
XML element named<Partner>. Within this class, all the Java members
(such as firstName and adress) should have their respective field
mappings, such as follows for e.g. the firstName member:

<field name="firstName" type="string">
     <bind-xml name="firstname" node="element" location="person" />
</class>

In addition, I'd use one more class Response for the root element (bound
to<response>  in your case), and define a field mapping for the Partner
class as follows:

<field name="partners" type="Partner" collection="...">
     <bind-xml name="Partner" node="element"
               location="life/liferesponse/Parent" />
</class>

Does this make sense to you ?

Cheers
Werner

On 11.02.2010 01:56, Sam-1234 wrote:

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

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

     http://xircles.codehaus.org/manage_email






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

   http://xircles.codehaus.org/manage_email


Reply via email to