[jdom-interest] The JDOM Model, Chapter 15 of Processing XML with Java

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon May 6 08:27:02 PDT 2002


I'd like to give this list early notice that I've posted The JDOM 
Model, Chapter 15 or Processing XML with Java, on my web site at

http://www.cafeconleche.org/books/xmljava/chapters/ch15.html

This chapter covers the design and use of the core classes in the 
org.jdom package in depth. A lot of the suggestions I've made over 
the last few weeks came about while writing this chapter. I'd 
appreciate it if anybody with a spare moment, look over it and let me 
know if they spot anything egregiously wrong. (Minor problem reports 
are also gracefully accepted of course.)

Writing this chapter and its predecessor was an enlightening 
experience. It's the first time I've really sat down with and thought 
about the entire JDOM API for over a year. A lot has changed since 
then. Some parts of it still strike me as very nice, but there are a 
couple of really big holes in the API and lots of pieces that don't 
feel like they fit with each other. I think JDOM is beginning to show 
the signs of design by committee. There are a lot of inconsistencies 
between classes and methods. Worse yet, features get added, removed, 
or vetoed based on vote and argument on the mailing list rather than 
on a guiding architectural vision.  The parts that seem to be the 
cleanest are the ones that have been touched by the fewest people. 
The filters are an example. The nastiest parts are those that have 
been touched by the most people. The Element class is probably the 
worst offender here.

I think what was lacking from the JDOM process was a clear XML 
vision. The Java vision was explicitly stated and never really 
challenged: classes instead of interfaces, all standard Java utility 
methods and interfaces provided, the collections API used where 
possible, standard naming conventions, no compromises made for 
compatibility with other languages. That part has held up very well. 
I think that's what developers  like about JDOM.

Unfortunately, JDOM never really had an equally compelling XML 
vision. This has led to a lot of weirdness and unanswered questions 
like:

1. What is a node?
2. What is the value of a node?
3. Why does JDOM call only elements children when every other XML 
specification uses the word "children" to refer to all kinds of nodes?
4. Does JDOM allow the creation of malformed documents or not?
5. What's more important? Performance or Correctness?
6. Are CDATA sections text nodes or not?
7. How should entities be handled?

On some of these issues, we've gone back and forth multiple times. I 
think a lot of this comes down to a failure to define early on a 
definitive data model for JDOM or to adopt one like the XPath 1.0 
model or the Infoset model. At one point, we did say that we'd 
provide full Infoset support, but we never really followed through on 
that, or perhaps grasped what we meant when we said it.

As an XML developer, JDOM frequently surprises me. That's not good. 
It makes the simple things simpler than DOM, but it makes the complex 
things  harder. When faced with a complex problem that requires me to 
consider all the nasty bits of XML and not just shallow documents 
with a few elements and attributes, then I turn to DOM, not JDOM. 
DOM's a mess; but it's mess is all on the Java side of the house. Its 
XML model, while imperfect, is very clear, very well-defined, and 
very consistent. JDOM's isn't. JDOM's mess is all on the XML side of 
the house.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list