Hi

I am using castor framework to unmarshall xml in my java code. I believe I
am using "castor-0.9.4.1.jar" (I say, I believe, because I am not too sure
about it. When I extracted the castor.jar it has a file "_
castor-0.9.4.1.jar _" at the root directory of the jar).

Here's my problem: My application parses an xml message for which the
required java classes have been generated using castor code generation. The
application is in production and has been working fine for over a year.
Recently my client introduced two extra tags in the xml and now (as
expected) it is throwing parser exceptions (*org.xml.sax.SAXException:
unable to find FieldDescriptor for 'tokenStatusxxx' in ClassDescriptor of
operator*).

I searched a lot for solution to this issue so that I don't have to do any
code change or even if I do need to change code, I should be able to do it
in such a way that further changes to xml should not require java code
change or code-generatation of classes based on new schema.

I found couple of solutions:

   1. org.exolab.castor.xml.strictelements=false
   2. Introduce mapping xml and set the field to [transient=true]  (ref:
   http://www.mail-archive.com/[email protected]/msg02892.html)
   3. Unmarshaller unm = new Unmarshaller(...); unm.*setIgnoreExtraElements*
   (true);

I have tried doing the above two approaches (1 & 2), but I am still not able
to make the parser ignore the extra elements. I am not able to use the third
approach because I do not see this "*setIgnoreExtraElements*" method on
Unmarshaller object. I do see the "setIgnoreExtraAttributes()" method but
NOT the "*setIgnoreExtraElements()*".

I do not have option to upgrade to latest version of castor to see if it
resolves my issues. I guess my question is are any of the above mentioned
approaches ONLY available in most recent versions of castor. Were they not
available in 0.9.4.1 version.

At this point my last option is to generate the code again based on new
schema and deliver the jar to client so that the new tags are parsed
correctly, even though my application has absolutely no use for those tags.

I would highly appreciate if some one help me with a solution that doesn't
require code-generation based on new schema.

Thanks
Subodh Natu

Reply via email to