Hi, 
 
I got this problem resolved with version 1.1 earlier I was using 1.0.5.
 
And my superclass is a concrete class.
 
Anyways, thanks for the time.
 
Rakesh

________________________________

From: Werner Guttmann [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 05, 2007 9:16 AM
To: [email protected]
Subject: AW: [castor-user] unmarshalling an Array of type superclass
having subclass elements



Hi,

 

Can I take it that you've read the xsi:type section of 

 

http://www.castor.org/xml-mapping.html#5.-xsi:type

 

especially the references to the auto-naming attribute ? 

 

Werner

 

________________________________

Von: Kumar, Rakesh [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 04. April 2007 18:47
An: [email protected]
Betreff: [castor-user] unmarshalling an Array of type superclass having
subclass elements

 

Hi,

 

 I have a requirement where in one of my classes(executive) have an
arraylist which is of type super class, let us say "reference". and this
arraylist can hold any of its sub classes , let us say "refphone"
"refaddress"   "refemail" etc...  

 

And the xml that I woule be unmarshalling would be something like

 


<?xml version="1.0" encoding="UTF-8"?>
<executive>
 <jobTitle>SE</jobTitle>
 <referenceList>
  <refAddress>
   <individualID>0</individualID>
   <address>
    <stateID>2</stateID>
    <countryID>4</countryID>
   </address>
   <addressID>0</addressID>
  </refAddress>
  <refAddress>
   <individualID>0</individualID>
   <address>
    <stateID>0</stateID>
    <countryID>0</countryID>
   </address>
   <addressID>0</addressID>
  </refAddress>
  <refEmail>
   <individualID>0</individualID>
   <email>
    <emailAddress>[EMAIL PROTECTED]</emailAddress>
    <activeEmailFlag>true</activeEmailFlag>
   </email>
  </refEmail>
 </referenceList>
</executive>

 

 

And I have defined the mapping as below.

 

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                         "http://castor.org/mapping.dtd";>
<mapping>
 <class name="com.busdb.domain.Executive">
  <map-to xml="executive"/>
  <field name="jobTitle" type="java.lang.String"/>
  <field name="propertyList" type="com.busdb.domain.Reference"
collection="arraylist" container="false" >
   <bind-xml name="propertyList"/>
  </field>
 </class>
 <class name="com.busdb.domain.Reference">
  <field name="individualID" type="java.lang.Long"/>
 </class>
 <class name="com.busdb.domain.RefAddress "
extends="com.busdb.domain.Reference" >
  <map-to xml="RefAddress"/>
  <field name="address" type="com.busdb.domain.Address"/>
 </class>
 <class name="com.busdb.domain.Address" >
  <map-to xml="address"/>
  <field name="addressLine1" type="java.lang.String">
   <bind-xml name="addressLine1"/>
  </field>
  <field name="postalCode" type="java.lang.String"/>
 </class>
 <class name="com.busdb.domain.RefEmail"
extends="com.busdb.domain.Reference">
  <map-to xml="refEmail"/>
  <field name="email" type="com.busdb.domain.Email">
    </field>
 </class>
 <class name="com.infousa.busdb.domain.Email" >
  <map-to xml="email"/>
  <field name="emailAddress" type="java.lang.String">
   <bind-xml name="emailAddress"/>
  </field>
 </class>
</mapping>

 

 

I tried to unmarshal the above xml , and mapping  to an "executive"
object. And surprisingly the first element of the arraylist of the
object generated has the XML tags in it something like below.

 

[<?xml version="1.0" encoding="UTF-8"?>

<refAddress>
   <individualID>0</individualID>
   <address>
    <stateID>2</stateID>
    <countryID>4</countryID>
   </address>
   <addressID>0</addressID>
  </refAddress>,<?xml version="1.0" encoding="UTF-8"?>

 <refAddress>
   <individualID>0</individualID>
   <address>
    <stateID>0</stateID>
    <countryID>0</countryID>
   </address>
   <addressID>0</addressID>
  </refAddress>,<?xml version="1.0" encoding="UTF-8"?>

  <refEmail>
   <individualID>0</individualID>
   <email>
    <emailAddress>[EMAIL PROTECTED]</emailAddress>
    <activeEmailFlag>true</activeEmailFlag>
   </email>
  </refEmail>]

How Do I get the refarraylist to be populated with different subclasses
of type reference?

Reply via email to