I'll dare to have a shot at it, see below the mapping code:
........................................................................................
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd";>
<mapping>
<class name="com.acme.model.Address">
<map-to xml="inputXML"/>
<field name="" type="com.acme.model.CurrentAddress">
<bind-xml name="CurrentAddress"/>
</field>
<field name="" type="com.acme.model.PreviousAddress">
<bind-xml name="PreviousAddress"/>
</field>
</class>


   <class name="com.acme.model.CurrentAddress">
       <field name="currentStreet" type="string">
          <bind-xml name="CurrentStreet" node="element"/>
       </field>
       <field name="currentState" type="string">
          <bind-xml name="CurrentState" node="element"/>
       </field>
       <field name="currentCity" type="string">
          <bind-xml name="CurrentCity" node="element"/>
       </field>
   </class>

   <class name="com.acme.model.PreviousAddress">
       <field name="previousStreet" type="string">
          <bind-xml name="PreviousStreet" node="element"/>
       </field>
       <field name="previousState" type="string">
          <bind-xml name="PreviousState" node="element"/>
       </field>
       <field name="previousCity" type="string">
          <bind-xml name="PreviousCity" node="element"/>
       </field>
   </class>
</mapping>
................................................................................................
Shital Tushar Agarkar wrote:

Hi,

I am new to Castor and does not know much about it. I want to use castor for marshelling and unmarshelling also.



My problem is: I have to use same class to represent two different elements in a xml file. Can anyone please help me in this?



I am elaborating my problem.



Sample outputXML:



<inputXML>

<CurrentAddress>

            <CurrentStreet>street1</CurrentStreet>

            <CurrerntState>State1</CurrentState>

            <CurrentCity>city1</CurrentCity>

</CurrentAddress>

<PreviousAddress>

            <PreviousStreet>street1</PreviousStreet>

            <PreviousState>State1</PreviousState>

            <PreviousCity>city1</PreviousCity>

</PreviousAddress>

</inputXML>





For this purpose I want to use Address class, to represent both the address elements. But I am not getting how to write mapping file for the same.



Guys, please help me in this .



Thanks in advance

-Shital



------------------------------------------------------------------------

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user





----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to