This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
OK, so we have an Object Model already that we use in our application. We have a web service with its XML schema defined already. The Object Model and XML are set and I need to be able to convert between the two easily. JAXB has the marshalling and unmarshalling of XML to Object and back.
For some reason in my head, I remember that you can generate Java files from an XML Schema and you can create an XML Schema from a Java Object. But what if you already have those two side defined. Can you just create a mapping file that maps the XML to the Object Model?
Or is there a seperate tool we should use. I know Castor looks like they have such a thing.
With DOM and XPath implementations, you do the dirty laundary. With Castor, it does the laundary for you with your schema as the input. I have known/worked on projects that relied on Castor (as opposed to ding it ourselves) and I assume they did their homework before going that way. So, I would go with Castor rather than DOM/XPath. My two cents.......
Just want to be sure of the question. Are you just trying to have some kind of Java-to-XML-to-Java mapping, and don't care about web services or JAXB? Or are you trying to use web services and/or JAXB, but want them to use a mapping you've already created?
As for performance, I haven't tried castor, but I did some testing to compare JAXB, XmlSchema, SAX, Digester, Stax. - stax was best if you could could keep a reference to your processor and keep reusing it - xmlschema was best if you couldn't keep a reference to your processor - jaxb was a close second to xmlschema when you couldn't keep a reference, and the jaxb type mappings are much more flexible.