I have to generate the classes from schema (XSD). Then I have to unmarhsall the XML into objects and then marshall the objects to XML. I have looked for various framework supporting that. I have looked for JAXB, Castor, XMLBeans, JIBX, Quick and Zeus. The finding are as: 1. Quick and Zeus does not support the class generation from XSD, only supports class generation from DTD. 2. JIBX does not support class generation from schema having enumeration or restriction tag. 3. JAXB supports generation of classes but could not unmarshall the XML (provided to me, although it supports unmarshalling from other XMLs), as XSD have only complex types, so could not generate the classes corresponding to the root element. So failed due to the binding problem with the XML provided to me. 4. Castor and XMLBeans are working fine. I am confused to use which of the approach. The problem is with the memory. I have run a lot of tests and have found that performance of XMLBeans is far better compared to Castor, but for larger XML (>20MB) the castor works fine but XMLBeans throws OutOfMemory Error. The observations are: ------------------------------- Memory| Castor | XMLBeans ------------------------------- 10MB | 10 sec | 3 sec 22MB | 16 sec | Failed 32MB | 18 sec | Failed 42MB | Failed | Failed The size of XML could be large, could anyone suggests how to improve the performance of castor or how could XMLBeans supports the much bigger XML. The heap memory allocated is 256MB and that is fixed.
- Posted by: Amit Arora
- Posted on: November 15 2007 00:45 EST
It sounds like JAXB wouldn't compile your Schema because it didn't have at least one global element definition to act as the document root. If that is the case, your Schema won't be able to validate any of your XML documents. You have to have at least one global element definition in a Schema to make it usable. Sorry if this is a stupid question, but have you actually validated your XML examples directly against the Schema? It wasn't obvious from the text whether you have, and your description of the Schema suggests that it wouldn't validate your examples. If it does validate them without errors, then something hasn't been properly described, and I would need more information to be able to say more. Cheers, Tony. -- Author, XML APIs chapter, "Advanced XML Applications from the Experts at The XML Guild" http://www.amazon.com/Advanced-XML-Applications-Experts-Guild/dp/1598632140/ref=sr_1_1?ie=UTF8&s=books&qid=1195115964&sr=1-1
My XSD is like: The root element here is 'index', but the JAXB generated the class for IndexType. There is no class corresponding to 'index' like Index.java . This is creating the problem with binding the XML into objects. So I have tried with Castor and XMLBeans. They are generating the class that could be used to unmarshall. I have validated the XML against the XSD and that is working fine. But the tradeoff between them is performance and memory. So I like to know how could we imporve the performance using castor or how could memory allocation problem be handled using castor.
Could you post the entire Schema? Thanks, Tony.