Hi:
I was wondering if this fix is included in Castor 0.9.4.1 
I am using this version and here is what I see:
I generated java objects for an XML schema using SourceGenerator (without changing 
"StrictElements" value in properties file). There is no mapping file involved.
The topmost element in the java object hierarchy is CIP (derived form the XSD root 
element). Unmarshalling an XML uses the following code:

FileReader reader = new FileReader(new File(_fileName));
cip = new CIP();
Unmarshaller um = new Unmarshaller(CIP.class);
um.setIgnoreExtraElements(true);
cip = (CIP)um.unmarshal(CIP.class, reader);

If the XML has extra elements that are not defined in the XSD and hence do not bind to 
any java objects, unmarshalling generates the following error:

Marshal Error: unable to find FieldDescriptor for 'AAA' in ClassDescriptor of CIP 
org.xml.sax.SAXException: 
unable to find FieldDescriptor for 'AAA' in ClassDescriptor of CIP      
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)

What am I missing? Please help. Thanks.
-------------------
Karuna Annavajjala
Software Architect
Ph: 614-865-6036
Fax: 614-865-6037

--- Original Message ---
This issue was fixed in the CVS yesterday.

Thanks,

--Keith


Gleb Tulukin wrote:
> 
> Hi,
> 
> FYI. Recently I faced the same problem (XML versioning). I searched the mail
> list archive and found the message below that addresses it. I am not sure
> which version the suggested fix was intended for -- I tried it does not work
> in castor 0.9.4. This is what I did and it seems to be working.
> 
> Problem: In Castor 0.9.4 when you use
> myUnmarshaler.setIgnoreExtraElements(true) and your XML file has extra
> elements you get NullPointerException in the endElement() because
> descriptor is null and thus if(descriptor.isContainer()) throws NullPointer.
> 
>    public void endElement(String name) throws org.xml.sax.SAXException
>     {
>         //......
>         UnmarshalState state = (UnmarshalState) _stateInfo.pop();
>         XMLFieldDescriptor descriptor = state.fieldDesc;
> 
. . . . . 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to