[jdom-interest] Re: Radical Suggestion

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

>That's true, accessing elements potentially gets really awkward when 
>you're dealing with arbitrary documents that have been read in. So 
>what could be done to simplify namespace handling for developers? 
>Maybe a way of creating an element without an explicit namespace 
>would help, where the element would assume the default namespace of 
>whereever it was put into the document.

Why would you ever want to do this? You're asking to allow somebody 
to take an XHTML table element, move it to a different part of the 
document, and have it magically morph into an XSL-FO table element, 
just because the namespace mappings in that section of the document 
are different. But you can't do that anyway. They are two different 
elements with different content models, different attribute lists, 
and different purposes. You cannot blindly replace one with the 
other. On the other hand, I very well might want to move a table from 
one part of the document to another and have it still be the same 
thing, even though the outer namespace is different. I do not see 
*any* use case for allowing elements to take on the local namespace 
mappings instead of maintaining their natural namespace, and 
substantial use cases for the existing behavior.

>For the access side, maybe what would really help would be easy ways 
>of accessing elements and attributes by local name while ignoring 
>their namespaces. I realize that from the XML POV this is a horrible 
>idea, but it suits what most developers are doing most of the time.

JDOM should help developers do things the right way, not the wrong 
way. If they want to use local names only, they can. Just don't put 
any namespaces in the documents. JDOM supports this fully and simply. 
However, if there are namespaces in a document, then the only 
sensible assumption is that there's a reason for them to be there, 
and ignoring them is potentially perilous.

>  It also reflects the way XML is actually used - cases where child 
>elements can have the same local name but different namespaces are 
>exceedingly rare in practice, as far as I've ever seen.

Not as uncommon as you might think. There are lots of mutual 
conflicts between XHTML, XSL-FO, SVG, RDF, MathML, etc.: table, set, 
a, text, style, script are just some of the elements that appear in 
more than one of these.

Use cases where elements have the same local name but different 
qualified names are very common. Searching for an XSL-FO table 
element must succeed even if the user is searching for fo:table and 
what they really have is table, xs:table, xsl-fo:table, or something 

| 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