Pisharath Krishnan wrote:
>
> I have an XML file as my input, and have modelled data
> objects to represent this data. I am trying to see if
> I can use Castor to unmarshal data into the object
> model, and marshal it back with modifications, using
> mapping files where needed.
>
> My XML file has something like this:
>
> ...
> <employee emp_type="xxx"> --other data---
> </employee>
> ...
>
> My object model has an Employee class, and two derived
> classes - Developer and Manager. I intend to
> instantiate one or the other of these two classes
> depending on the value of emp_type.
>
> How can I accomplish this using Castor ? Is there any
> way to specify this in the mapping file or somewhere
> else?
No...you need to do:
<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="manager">
</employee>
-or-
<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="com.acme.Manager">
</employee>
If you can't change the way the XML will look, then you may need to do
an XSLT transformation before and after marshalling to get your desire
result.
--Keith
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev