Thanks for your help. I tried to use XMLClassDescriptorResolver with Marshaller but Java objects do not get marshalled properly(I got lots of unnecessary tags in generated XML). I think it uses default descriptor loading mechanism.

Generated XML :
<?xml version="1.0" encoding="UTF-8"?>
<description dirty="false" persisted="false">
   <description-text>This is test</description-text>
   <column-method-mapping-data op-type="1" col-index="0">
       <table-col-name>id</table-col-name>
       <method-name>getId</method-name>
   ...
....

One of the note in best practices site says "For some of the methods, pre-loading class descriptors will only work if you provide the .castor.cdr file with your generated classes" and I dont use generated classes, instead I use my own classes. Let me add my marshalling code so that you might be able to suggest.

XMLClassDescriptorResolver classDescriptorResolver = (XMLClassDescriptorResolver) ClassDescriptorResolverFactory.createClassDescriptorResolver(BindingType.XML); classDescriptorResolver.addClass("com.yamaha.portal.site.transport.Description");

Writer writer = new FileWriter("test1.xml");
           Marshaller marshaller = new Marshaller();
           marshaller.setWriter(writer);
marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
           marshaller.marshal(desc);

Let me know if I am doing anything wrong.

regards,
Ranjan

Werner Guttmann wrote:
Sure. Have a look at

http://www.castor.org/xml-best-practice.html

for instructions on how to use the xml class descriptor resolver. Other than that, you could consider using the new XMLContext class which will give you a preconfigured XMLClassDescriptorResolver anyhow. Instructions for using this new classare available at

http://www.castor.org/xml-framework.html#Using-XMLContext-to-bootstrap-Castor

Regards
Werner

P.S. A search on the mailing list archives for terms such as 'usage' and 'XMLClassDescriptorResolver' might have revealed some intersting things to read. The archives are available at

http://archive.castor.codehaus.org

Ranjan Kumar Baisak wrote:
Werner Guttmann wrote:
Before starting to have a close look, I wonder whether it would make a difference to switch to using the XMLClassDescriptorResolver instead.

Could you please throw some examples for using XMLClassDescriptorResolver?
regards,
Ranjan


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

   http://xircles.codehaus.org/manage_email





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

   http://xircles.codehaus.org/manage_email




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

   http://xircles.codehaus.org/manage_email

Reply via email to