Is there a common way to marshall and unmarshall (Java to XML and
vice-versa), using either binding or mapping files created with Castor
source generator.   I've it working using the following 2 different API
calls (one for binding vs another for mapping)), but I'm looking to have
one single way independent of whether it used binding or mapping files
to generate the Castor source java files.  We are using Castor v 1.0.5,
but also invite your inputs to any version which has such a feature.
 
Thanks
Kannan
 
 
Using binding files:
Response.unmarshal(new StringReader(inputStr))

 

Using mapping files:

MappingLoader mappingLoader =
mappingUnmarshaller.getMappingLoader(mapping, BindingType.XML);

classDescriptorResolver.setMappingLoader(mappingLoader); 

 Unmarshaller unmar = new Unmarshaller(response);

unmar.setResolver((XMLClassDescriptorResolver)classDescriptorResolver);

unmar.setWhitespacePreserve(true); 

unmar.setIgnoreExtraElements(true);

retObj = (Object) unmar.unmarshal((Element) payload);

 

Reply via email to