Castor XML mapping
843834Dec 30 2004 — edited Nov 22 2006I 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