Balaji,
You're in luck! :-)
There is a new feature in the 0.9.5.3 RC1 that allows you to nest a
class mapping, so you can change the mapping for the company field:
<field name="company" type="ClientData">
<bind-xml node="element">
<!-- custom mapping for ClientData -->
<class name="ClientData">
<field name="name" type="string">
<bind-xml name="CompanyName"/>
</field>
...
</class>
</bind-xml>
</field>
--Keith
> "Adikesavelu, Balaji" wrote:
>
> I have a common Java Object type, but the XML representation is in
> different elements.
>
> For the sake of the discussion, I have changed the MyOrder.java to
> illustrate my case:
>
> I added another member _company of type ClientData. Please note that
> in the Order.XML the name and address elements are represented as
> companyname and companyAddress.
>
> How do I handle the mapping for the ClientData?
>
> Listing of MyOrder.java:
>
> /*
> * Created on Feb 9, 2004
> *
> * To change the template for this generated file go to
> * Window>Preferences>Java>Code Generation>Code and
> Comments
> */
> package castorMapping;
>
> /**
> * @author A249234
> *
> * To change the template for this generated type comment go to
> * Window>Preferences>Java>Code Generation>Code and
> Comments
> */
> import java.util.Vector;
> import java.util.Enumeration;
>
> public class MyOrder {
>
> private String _ref;
> private ClientData _client;
> private ClientData _company;
> private Vector _items;
> private float _total;
>
> ......... all the remaining code.
> ........
> ........
> public ClientData getCompany() {
> return _company;
> }
>
> /**
> * @param data
> */
> public void setCompany(ClientData data) {
> _company = data;
> }
>
> }
>
> Listing of Order.xml:
> <Order reference="12343-AHSHE-314159">
> <Client>
> <Name>Jean Smith</Name>
> <Address>2000, Alameda de las Pulgas, San Mateo, CA
> 94403</Address>
> </Client>
> <Company>
> <CompanyName>Jean Smith</CompanyName>>
> <CompanyAddress>2000, Alameda de las Pulgas, San
> Mateo, CA 94403</CompanyAddress>>
> </Company>
>
> <Item reference="RF-0001">
> <Description>Stuffed Penguin</Description>
> <Quantity>10</Quantity>
> <UnitPrice>8.95</UnitPrice>
> </Item>
>
> <Item reference="RF-0034">
> <Description>Chocolate</Description>
> <Quantity>5</Quantity>
> <UnitPrice>28.50</UnitPrice>
> </Item>
>
> <Item reference="RF-3341">
> <Description>Cookie</Description>
> <Quantity>30</Quantity>
> <UnitPrice>0.85</UnitPrice>
> </Item>
> </Order>
>
> Thanks
>
> Any help would be greatly appreciated.
>
> Balaji
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev