After some tests I've come up with a solution that works (at least):
The mapping of tag <a> and class Ja would look like:
<class name="Ja">
<map-to xml="a"/>
<field name="b" type="Jb" required="false" get-method="getX" set-method="setX">
<bind-xml name="b" node="element"/>
</field>
<field name="c" type="Jc" required="false" get-method="getX" set-method="setX">
<bind-xml name="c" node="element"/>
</field>
<field name="d" type="Jd" required="false" get-method="getX" set-method="setX">
<bind-xml name="d" node="element"/>
</field>
</class>
What is actually done is fooling castor into thinking that class Ja has three fields
of different names and types, and that all fields have the same setter and getter
method. This is possible because classes Jb, Jc and Jd have the same superclass.
If anyone has a better or more elegant solution, I's be very interrested.
Regards,
Bas
> I have a question about Castor mapping files:
> We're developing an application for Lucent Technologies and
> in this project we have an XML file of the following form:
> <a>
> <b> </b>
> </a>
> <a>
> <c> </c>
> <a>
> <a>
> <d> </d>
> <a>
> So actually, the element in <a> is a choice between b, c and d
>
> We have a java class structure like
>
> class Ja {
> Jx x;
> }
>
> abstract class Jx{}
>
> class Jb extends Jx{}
> class Jc extends Jx{}
> class Jd extends Jx{}
>
> We are trying to map the xml file above to the java structure
> with one mapping file.
> Is this possible, and if yes, how?
>
> I've tried to find this in the Castor documentation, but
> can't seem to find anything like it.
> Could you help me with this problem?
>
> Regards,
> Bas Velthuizen
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev