Hi keith,
<class name="com.acme.Person">
...
<field name="firstname" type="string">
<bind-xml name="firstname" node="attribute" location="name"/>
</field>
...
</class>
In the above xml suppose i want to make changes and introduce one more field
email
<class name="com.acme.Person">
...
<field name="firstname" type="string">
<bind-xml name="firstname" node="attribute" location="name"/>
</field>
<field name="email" type="string">
<bind-xml name="Email-id" node="attribute" location="firstname"/>
</field>
...
</class>
I want the attribute email to be part of element firstname will this
work?????
I have tried this out.It does not work.It gets added as an attribute of
class name.
How should i solve this problem??????
thanks in advance......
Ashish
-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]
Sent: Friday, December 05, 2003 5:35 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] FW: Mapping of attributes in castor with the
corresponding java bean
"Ashish Goswami, Noida" wrote:
>
> Hi
>
> i would like to know if i have an xml
>
> <person>
> <name firstname="ashish" lastname="goswami"/>
> <email public="true">[EMAIL PROTECTED]</email>
> </person>
>
> While writing mapping.xml will i have to create seperate class for name
and
> emailid and person.
No, you can use the "location" attribute on the bind-xml element of the
mapping to do what you want.
eg:
<class name="com.acme.Person">
...
<field name="firstname" type="string">
<bind-xml name="firstname" node="attribute" location="name"/>
</field>
...
</class>
--Keith
Because if i write get set methods for attributes
> firstname and lastname in the person class they would appear as attributes
> for person element.Creating aseperate class name and adding get set
methods
> for lastname and firstname solves this problem.Now i want to know is there
> any other way to solve this problem.Because in my xml i have multiple
> elements which have nodes as attributes.creating classes for each one of
> them would be cumbersome.....
>
> thanks in advance,
>
> ashish goswami
>
> -----Original Message-----
> From: Ashish Goswami, Noida [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 03, 2003 5:18 PM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] FW: Mapping of attributes in castor with the
> corresponding java bean
>
>
>
> > hi!
> >
> > I am a new bie to castor .I am talking about mapping of xml document to
> > java bean class.
> > i have xml where multiple elements have attributes.Do i need to create
> > a class for each element in the xml?????And in that class have get set
> > methods for the attributes for that
> > element???????please let me know how do i go about solving this simple
> > problem.It works well when i create class
> > for each element and have get set methods for each attributes in the
> > element. This problem may not work out if all
> > elements in the xml have attributes. is there alternative to this
> > problem?????
> >
> > thanks in advance.
> >
> > Ashish
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev