Jana,
To load a mapping file you do it as such:
Mapping mapping = new Mapping();
mapping.loadMapping("mapping.xml");
To set it in the Unmarshaller you do the following:
Unmarshaller unm = new Unmarshaller(Response.class);
unm.setMapping(mapping);
Response res = (Response)unm.unmarshal(in);
--Keith
janarthanankesavan wrote:
>
> Hi,
> While unmarshalling i get the following error:
>
> org.xml.sax.SAXException: The class for the root element 'mapping' could not be
> found.
>
> How to get rid of this?
>
> My unmarshaller code:
> abc=(Response)unmarshaller.unmarshal(in);
>
> My mapping file used for unmarshalling:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <mapping xmlns="http://castor.exolab.org/" xmlns:cst="http://castor.exolab.org/">
>
> <class name="com.test.ResponseABC">
> <map-to xml="abc" />
> <field name="header" type="com.test.Header" >
> <bind-xml name="header"/>
> </field>
> <field name="body" type="com.test.Response" >
> <bind-xml name="body"/>
> </field>
> <field name="fault" type="com.test.Fault" >
> <bind-xml name="fault"/>
> </field>
> </class>
>
> <class name="com.test.Header">
>
> <field name="head" type="java.lang.String" >
> <bind-xml name="head" />
> </field>
> </class>
>
> <class name="com.test.Response">
> <field name="info" type="com.test.Info" />
> <field name="result" type="java.lang.String" />
> </class>
>
> <class name="com.test.Info">
>
> <field name="date" type="java.lang.String" >
> <bind-xml name="date"/>
> </field>
> <field name="time" type="java.lang.String" >
> <bind-xml name="time"/>
> </field>
> </class>
>
> <class name="com.test.Fault">
> <field name="fault" type="java.lang.String" >
> <bind-xml name="fault" />
> </field>
> </class>
>
> </mapping>
>
> Thanks and regards,
> Jana
>
> ------------------------------------------------------------------------
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user