Lists Home |
Date Index |
Robert Koberg wrote:
> I just googled looking for a comparison between XOM and dom4j (what i am
> currently using) and only found your comparisoin to JDOM. Looking at the
> XOM information at your site (http://www.cafeconleche.org/XOM/), it
> looks like XOM and dom4j are similar. Is that the case?
XOM and dom4j were both inspired by JDOM. Neither uses any JDOM code.
dom4j was started by a developer who was dissatisfied with JDOM, and
wanted to add to it. XOM was started by a developer who was dissatisfied
with JDOM, and wanted to subtract from it.
One of the many things dom4j adds to JDOM (conceptually, not in code) is
complete support for DOM interfaces. In other words, a dom4j Element is
also a DOM2 element. This means dom4j offers all the complexity and
confusion of DOM, plus its own complexity and confusion on top of that.
Somehow this doesn't feel to me like progress. To make matters worse,
dom4j isn't really a conformant implementation of DOM. A lot of the
methods don't do exactly what the DOM specification says they should.
XOM does not implement DOM. There's only one API to learn and use, and
its simpler than any tree-based API I've seen in Java. It focuses on
correctness, simplicity, and performance, *in that order*. JDOM allows
you to create malformed documents, as do DOM and dom4j. It is simply
impossible to create a namespace malformed document in XOM (or if it
isn't, it's a bug; and I will fix it when it's pointed out.)
> I am using less memory after switching from JDOM to dom4j. Would there
> be a similar benefit going from dom4j to XOM? Do you have any critiques
> of dom4j in favor of XOM? (I am open to switching.)
I've done a lot of memory profiling on XOM and made serious efforts to
reduce its memory usage. Right now it seems to need somewhere between 4
and 5 times the size of the input document to store the model in memory.
There are a few more optimizations I plan to explore in the future,
and I hope to get that down to maybe a factor of 3 (though not in 1.0).
I don't know what sort of memory profiles JDOM and dom4j have so I can't
XOM does offer a streaming mode in which documents can be processed one
subtree at a time without storing everything in memory so it can process
documents much larger than available memory. JDOM has something similar,
but I think XOM's support for this is better documented and better
Elliotte Rusty Harold email@example.com
XML in a Nutshell 3rd Edition Just Published!