JAXB 2.0 doesn’t look so cool

I’ve been thinking I wanted to learn about JAXB 2.0, because DOM (and SAX) code usually looks gross and is gross to write. To start learning, I visited this tutorial linked from the JAXB reference implementation home page and I think I’ve learned enough.

For a simple XML schema which defines 8 elements, the JAXB compiler generates 45 Java classes spread over 3 packages. To use the classes, I need to include 7 jar files in my application.

I’m going to stick to the DOM.

5 Responses to “JAXB 2.0 doesn’t look so cool”

  1. Charlie Hayes Says:

    Wow, thats crazy! 45 classes is insane.

  2. Doug Says:

    Take a look at the Castor project. It’s much simpler to learn and use than JAXB and still quite powerful. Worth a look.

    There are a couple of other libraries that are similar whose names I can’t remember. One is at Apache, XML Beans I think.

    Doug

  3. Jos Dirksen Says:

    The tutorial you referenced doesn’t seem to use jaxb 2.0, but JAXB 1.0.5. From the release notes of JAXB2.0 apparently the number of classes generated is significantly reduced and the jars you need to include also seem to made smaller.

    You might try that version before going back to dom…

  4. Xin Zhao Says:

    Try Liquid XML.

  5. Phillip Tornroth Says:

    I’ve had the same issue with just about every piece of XML parsing code I’ve written, DOM/SAX/JAXB/Castor.. they’re all obnoxious. It occured to me this week that the most freedom I’ve experienced peeling information out of XML has been when writing XSL documents, and that was because of XPath. I hooked up the JAXP XPath API’s yesterday and wrote some code… I am sooo much more pleased with it than I’ve been with anything else. It’s essentially still DOM code, but instead of walking the entire tree, you end up searching to get down the Node or NodeSet you want to deal with. For small parsing jobs, it’s definitely the way I’m going from now on. I can send code if anyone’s curious, but there are some examples floating about.

Leave a Reply