26

Anyone can tell me which one is better (JAXB or Apache XMLBeans) taking in account the performance for files bigger than 10Mb?

informatik01
  • 16,038
  • 10
  • 74
  • 104
Simon
  • 325
  • 1
  • 5
  • 7
  • 1
    **As a side note to developers:** currently XMLBeans project is officially retired and active development is ceased. Pay attention to the message on top of the Apache XMLBeans [home page](https://xmlbeans.apache.org/) (quote): _"2014/05/23 - Apache XMLBeans has been **retired**. For more information, please explore the [Apache Attic](http://attic.apache.org/projects/xmlbeans.html)."_ – informatik01 Aug 22 '16 at 13:26
  • XMLBeans came back from attic it seams... `Project Apache XMLBeans was in the Attic from July 2013 until June 2018.` – Julien Oct 07 '20 at 12:36

4 Answers4

17

Both have similar performances, however even if Apache XMLBeans seems to present better performance, I normally choose JAXB because I don't want to increase the size of my applications with 3rd party tools.

With Apache XMLBeans you need a small package around 2mb, it's probably easy to learn and well documented. Have full support of XSD specification and namespaces, and mapping only via XML Schema Definition (XSD). It also seems to use deprecated API’s.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Bruno Simões
  • 721
  • 5
  • 12
  • 1
    I'm trying to create a webstart application so the size of the final application is very important and probably the heaviest factor in my decision since the difference in performance is not too big. – Simon Sep 01 '09 at 12:19
8

The architect of XmlBeans wrote about why he chose to build XmlBeans, even though JAXB was the established standard. Take a look at his blog, specifically the problems with jaxb The most compelling advantage was type substitution.

Roger Weber
  • 89
  • 1
  • 1
  • 16
    The `problems with jaxb` blog post is in reference to JAXB 1 (JSR-31). JAXB 2 (JSR-222) is leaps and bounds better. This is due in part to contributions made by David Bau who was a member of the JAXB 2 expert group. – bdoughan Sep 20 '11 at 15:04
4

I prefer XMLBeans, because it comes with a handy tool called "inst2xsd" which allows you to generate an XML schema from an XML instance document. JAXB is not able to do this.

See http://xmlbeans.apache.org/docs/2.0.0/guide/tools.html#inst2xsd

rwitzel
  • 1,694
  • 17
  • 21
dogbane
  • 266,786
  • 75
  • 396
  • 414
  • 5
    JAXB 2 can generate XML Schemas, see http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/javax/xml/bind/JAXBContext.html#generateSchema(javax.xml.bind.SchemaOutputResolver) – bdoughan Jul 09 '10 at 21:03
  • 3
    JAXB 2 cannot generate schema from xml. The schemagen tool only generates schema from java classes. – Kamran Sep 23 '13 at 16:13
  • See http://stackoverflow.com/questions/7212064/is-it-possible-to-generate-a-xsd-from-a-jaxb-annotated-class :) – everlasto Nov 11 '13 at 11:29
  • 1
    @everlasto: As Kamran pointed out, the comment is about generation from XML instance files. – rwitzel Apr 16 '14 at 21:02
1

agree with bruno. JAXB is bundled with Java for a reason

Nico
  • 1,954
  • 2
  • 14
  • 18
  • 4
    No, because it won the xml-java-object-mapping-tool lottery :) – Nico Sep 01 '09 at 18:48
  • 10
    JAXB is not a tool but a spec (http://jcp.org/en/jsr/detail?id=222). The Metro JAXB impl (https://jaxb.dev.java.net/) is included in Java SE 6. There are other JAXB impls such as MOXy (http://www.eclipse.org/eclipselink/moxy.php) and JaxMe (http://ws.apache.org/jaxme/). – bdoughan Sep 10 '10 at 14:41
  • 1
    its removed since JDK11 – caduceus Dec 03 '20 at 20:47