Rughwani,
When u r marshalling more than more java object into the same xml file, you can use some base element as follows.
<castor-container> <cls1> <id>123</id> <name>abc</name> </cls1> <cls1> <id>234</id> <name>bcd</name> </cls1> <cls1> <id>345</id> <name>cde</name> </cls1> </castor-container>
Here, cls1 is the java object that u want to marshall/unmarshall.
When u want to unmarshall the above xml file, one approach is to use a dummy container class.
Class CastorContainer
{
Vector object1;
public void setObject1(Vector v)
{
object1 = v;
}
public Vector getObject1()
{
return object1;
}
}
Mapping file.
<mapping>
<class name="CastorContainer" auto-complete="false">
<description>Default mapping for class CastorContainer</description>
<map-to xml="castor-container"/>
<field name="object1" type="Cls1" collection="vector" required="false">
<bind-xml name="cls1"/>
</field>
</class>
<class name="Cls1">
< field name="id" type="string" >
<bind-xml name="id" node="element"/>
</field>
< field name="name" type="string" >
<bind-xml name="name" node="element"/>
</field>
</class>
</mapping>
I think there are other approaches as well, but this approach works for me. But you have to create an additional class. ( in this case CastorContainer). This class is generic enuf to use it for any set of elements that you want to unmarshall/marshall.
Hope this helps.
/ rAVI.
Rughwani, Devashish (Devashish) wrote:
Hi All
I have tried out some basic examples like marshalling a Java Object into a XML using mapping file.It marshals One Java Object into one XML file
I want to know How to Marshal many Java Objects of the same type into a SINGLE XML file ? Could you please point me to some examples ?
Thanks in advance
Devashish
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
