[jdom-interest] Re: Radical Suggestion

Elliotte Rusty Harold elharo at metalab.unc.edu
Sun Jul 28 17:09:38 PDT 2002

At 2:11 PM -0400 7/28/02, Alex Rosen wrote:

>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.)

DOM does this (you have to give elements and explicit namespaces and 
provide namespace declaration attributes) and it's a bloody mess. It 
confuses everyone, and it makes it very easy to create documents that 
cannot be serialized as namespace well-formed text.

Using pure namespace declarations only, is a little more consistent 
and straight-forward, though again it would make it nigh-on 
impossible to auto-maintain namespace well-formedness. For example,

Element e = new Element("svg:text");

Whether or not this element is well-formed depends on where it goes 
in the tree.   As initially created it would be malformed until an 
xmlns:svg="http://..." attribute were added to it or one of its 

JDOM has the right model for namespaces. Developers have trouble with 
it because they often don't understand namespaces. That's good. 
Better the errors in their understanding be exposed quickly than be 
allowed to propagate and cause further, bigger problems down the line.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
|              http://www.cafeconleche.org/books/xian2/              |
|  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/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