[jdom-interest] Is JDOM dying?

Alex Rosen arosen at novell.com
Sat Mar 15 09:23:14 PST 2003


"The fact that JDOM does not allow inheritance, IMHO, is a show-stopping
bug."

Like lots of other people, I felt this way too when I was new to JDOM:

> It's perfectly
> natural to think of XML in terms of its textual representation, so
that's how
> many (most?) people build XML trees. If you "think about it hard
enough", you
> realize that the current behavior makes sense, but that won't stop
people from
> thinking about it the other way, and getting confused.

But after we flamed about it on this list for a long time (one of
several times that we did this), I realized that the current JDOM system
is the best system, or maybe just the least bad:

>I have a lot of sympathy for your suggestion when it comes to
>creating documents. Basically it sounds like you're suggesting using
>namespace declarations instead of namespaces in the API. This is how a
lot
>of people tend to think of it, and it's not at all inconsistent with
XML if
>you describe it in that way. However, when reading documents instead
of
>creating them, this model falls apart. To read a document correctly,
you
>absolutely want to look at the namespace, not the namespace
declaration. In
>this case, people who want to do getChild("name") to find a child
that's in
>the default namespace are simply wrong; it'll work fine most of the
time,
>but then they'll run in to a document that declares its namespaces
>differently but is logically equivalent, and it'll fail. To me this is
proof
>enough that we've got the right API, even though it may be confusing
to
>people at first. (I suppose we could support both systems, one for
reading
>and one for creating, but that seems way worse.)

And:

>I think a big problem is that it's easy to confuse the concepts of a
>namespace and a namespace declaration. What you see in an XML document
is
>the namespace declaration, and even if you know how namespaces work
it's
>easy to space out and think that the parent element has a namespace
but the
>child doesn't. Pointing this distinction out in a few more places in
the
>JavaDoc might help.

"I think you are right about the representation... I think JDOM is more
like a
more-convenient DOM concept -- whereas I would prefer something that
reads/writes
the XML as seen in the textual representation -- after all, that is how
the tutorials
teach it, you read it, you write it, etc etc...."

As I mentioned above, an API that works on the textual representation
of an XML document works fine for writing, but is wrong for reading.
There are many different textual XML files that correspond to a given
logical XML document, and your system would force the user to do a lot
of checks, running up and down the document, to figure out which
namespace the element is *really* in. (Plus, as Philip points out, I
think that SAX wouldn't let us do this even if we wanted to.)

Alex Rosen
Novell, Inc.

P.S. Here are the messages I'm quoting, if you want to go back and read
the previous discussions.

http://www.servlets.com/archive/servlet/ReadMsg?msgId=7390&listName=jdom-interest

http://www.servlets.com/archive/servlet/ReadMsg?msgId=249266&listName=jdom-interest

http://www.servlets.com/archive/servlet/ReadMsg?msgId=249020&listName=jdom-interest






More information about the jdom-interest mailing list