Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Castor XML mapping

843834Dec 30 2004 — edited Nov 22 2006
I am using and XML and trying to map to a class. I do not want to fit all the fields in XML to fields in java class.

For example: I have fields field1, field2, field3 in XML. But my java class wants only field1 and field2 and NOT field3. How do I do it. I want to ignore field3.

Mapping map = new Mapping();
map.loadMapping("mapping.xml");
Reader reader = new FileReader("abc.xml");
Unmarshaller unmarshaller = new Unmarshaller(map);
ABCClass read = (ABCClass)unmarshaller.unmarshal(reader);
System.out.println(read);

Getting error: unable to find FieldDescriptor for field3' in ClassDescriptor of ABC-Class

Above error looks very logical. I don't want to check java class for all the tags/fields in XML doc,
I guess this is a general requirement in many cases and simple to solve.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 20 2006
Added on Dec 30 2004
7 comments
4,062 views