Hi Keith, Thanks for the prompt response.

Actually, I currently am using the

unmarshaller.setIgnoreExtraElements(true);

This works fine, for instance, when I add a <keith> tag at any level to my
XML. There are no problems
with the unmarshalling.

It does not work ONLY when, for instance, <keith> is mapped at level <A>
and NOT mapped at level <B>
and <keith> appears in the XML at level <B>.

Regards
Vamsi




                                                                                       
                                         
                      Keith Visco                                                      
                                         
                      <[EMAIL PROTECTED]       To:       [EMAIL PROTECTED]             
                                     
                      m>                       cc:                                     
                                         
                                               Subject:  Re: [castor-dev] Castor 
Unmarshalling problem                          
                      02/18/2004 01:58                                                 
                                         
                      PM                                                               
                                         
                      Please respond to                                                
                                         
                      castor-dev                                                       
                                         
                                                                                       
                                         
                                                                                       
                                         






Hi Vamsi,

Just turn-on Castor's ability to ignore extra elements:

myUnmarshaller.setIgnoreExtraElements(true);
MyObject root = (MyObject)myUnmarshaller.unmarshal(reader);

--Keith

Vamsi Mohun/AT-Austin/3M/US wrote:
>
> All,
>
> I posted this originally on 09/10/2003 (
> http://www.mail-archive.com/[EMAIL PROTECTED]/msg15104.html)
> but never got any responses. Hoping for a response this time.
>
> Thanks in Advance
> Vamsi
>
> I have this xsd.
>
> <?xml version="1.0"?>
> <xsd:schema
>             xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>             targetNamespace = "http://www.webMethods.com/noNamespace/";
>             xmlns = "http://www.webMethods.com/noNamespace/";
>             xmlns:ST1 = "http://www.webMethods.com/noNamespace/";>
>     </xsd:complexType name="A">
>         <xsd:sequence>
>             <xsd:element name="first" type="xsd:token" minOccurs="0"
> maxOccurs="1"/>
>             <xsd:element name="second" type="xsd:token" minOccurs="0"
> maxOccurs="1"/>
>             <xsd:element name="B" type="B" minOccurs="0"
> maxOccurs="unbounded"/>
>         <xsd:sequence>
>     </xsd:complexType>
>     </xsd:complexType name="B">
>         <xsd:sequence>
>             <xsd:element name="second" type="xsd:token" minOccurs="0"
> maxOccurs="1"/>
>             <xsd:element name="third" type="xsd:token" minOccurs="0"
> maxOccurs="1"/>
>         <xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
>
> mapping.xml
>
> <?xml version="1.0"?>
> <?xml version="1.0"?>
> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0
> //EN"
>                          "mapping.dtd">
>
> <mapping>
>   <class name="A">
>     <map-to xml="A"/>
>     <field name="first" type="string">
>       <bind-xml name="first" node="element"/>
>     </field>
>     <field name="second" type="string">
>       <bind-xml name="second" node="element"/>
>     </field>
>   </class>
>
>   <class name="B">
>     <map-to xml="B"/>
>     <field name="third" type="string">
>       <bind-xml name="third" node="element"/>
>     </field>
>   </class>
>
> NOTICE that even though "second" is defined in the xsd, it is NOT defined
> in
> mapping.xml.
>
> Now when I try to unmarshal this XML,
>
> <?xml version="1.0"?>
> <A>
>   <first>something</first>
>   <second>something</second>
>     <B>
>       <second>something</second>
>       <third>something</third>
>     </B>
> </A>
>
> I get the following exception.
> Failed to parse xml:org.xml.sax.SAXException: ....
> java.lang.IllegalArgumentException: Type conversion error: could not set
> value of "second"
> in "B".
>
> The "second" field is defined in the XSD and in the XML. But it is NOT
> defined
> in mapping.xml. This is because I am not interested in this field. Should
> and can
> castor handle this?
>
> -----------------------------------------------------------
> 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

Reply via email to