Hi,

just to add a bit more clarity before trying to address your question.
When you use the Castor XML code generator to generate Java source files
 from an XML schema, you'll see that an additional set of classes will
be generated, i.e. the descriptor classes. It's those files that
completely replace a mapping file during XML data binding.

So for the remainder of this, let's use the term 'descriptor classes':



Jayaraman, Kannan wrote:
>  
> 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))
It's not that you have to use this method for unmarshalling. Why not
switch to the same method as highlighted below for the mapping ? You can
even turn off generation of the marshalling methods completely.
> 
>  
> 
> 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);
> 
>  
> 
> 


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to