Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java XML Binding [closed]

Tags:

What are you using for binding XML to Java? JAXB, Castor, and XMLBeans are some of the available choices. The comparisons that I've seen are all three or four years old. I'm open to other suggestions. Marshalling / unmarshalling performance and ease of use are of particular interest.

Clarification: I'd like to see not just what framework you use, but your reasoning for using one over the others.

like image 837
Paul Croarkin Avatar asked Oct 15 '08 17:10

Paul Croarkin


Video Answer


1 Answers

If you want to make an informed decision you need to be clear why you are translating between XML and java objects. The reason being that the different technologies in this space try to solve different problems. The different tools fall into two categories:

  1. XML data binding - refers to the process of representing the information in an XML document as an object in computer memory. Typically, this means defining an XSD and generating a java source code equivalent. Interop between different languages is top priority (hence the use of XSD) - most typically for the implementation of SOAP-based web services.
  2. XML serialisation - refers to writing out a graph of in memory objects to a stream, so that it can be reconstituted somewhere or sometime else. You write the java classes by hand; the xml representation is of secondary importance. Also, the need for performance is often greater and the need for interoperation with other languages such as .net is often lower.

For xml serialisation, Xstream is hard to beat. JAXB is the standard for XML binding.

In either case, if you are using J2EE you'll need to pay careful attention to classes retrieved from JPA since class proxies and persistence specific collection types can confuse binding / serialization tools.

like image 111
johnstok Avatar answered Sep 19 '22 11:09

johnstok