Which one is better for code generation for code generation, XMLBeans or JAXB?

Want to use the XML schema library to generate code and want to know if people have preferences between XMLBeans and JAXB. Performance, the ability to check the circuit, memory usage .. Any indicators will help ..

+4
source share
5 answers

My personal preference would be JAXB. It has a more modern approach using annotations and many of the features of Java 5. XMLBeans, on the other hand, is still compatible with Java 1.4 - if it is required for you. Some other thoughts, in particular, are not:

  • From Java 6 to JAXB bundled with the JDK - so it is available out of the box.
  • JAXB Works with Annotated Java Classes (POJOs) - XMLBeans-Generated Interfaces and Classes
  • JAXB allows you to comment on Java classes to use to sort and cancel routing, or you can start with an XML schema, generate Java classes, and then fo in un- / marshalling
  • XMLBeans only allows you to start with an XML schema, create interfaces, and then use this for un- / marshalling
+11
source

+1 for Joachim's answer, and to add one of my favorite features, JAXB 2.0 creates Java lists from limited simple types.

+1
source

Another advantage of JAXB is that since you work with POJOs, you can feel comfortable using them as first-class class objects and use them in your application stack.

Want to use them as value objects for your DAO layer? How about your model in the user interface layer? Go for it.

Thus, you have fewer display layers and DTOs, which means less code to write, test, and support.

+1
source

XmlObjects are also first class domain and DTO objects, as well as view objects with easy access to xml information for effective analysis. As a rule, business objects are too coarse, so some mappings will have to be implemented anyway for both XmlBeans and JAXB using DTO or assemblers. JAXB offers marshalling time checks and is better integrated with the infrastructure, but I think the benefits of XmlBeans are stronger than the benefits of JAXB.

+1
source

I prefer XMLBeans because it comes with a handy tool called "inst2xsd" that allows you to generate a schema from an XML document. JAXB can compile circuits, rather than generate them.

0
source