[jdom-interest] Default Namespace vs No-Namespace.
Elliotte Rusty Harold
elharo at metalab.unc.edu
Fri Jul 4 04:51:55 PDT 2003
At 11:02 AM -0700 7/3/03, John Jefferson wrote:
>Maybe you can enlighten me on this point. Or point me
>to something easier to digest than the xml namespace
>spec.
I recommend the namespaces chapters in my own XML in a Nutshell or
the XML Bible, 2nd Edition. Or see
http://www.cafeconleche.org/books/xmljava/chapters/ch01s02.html#d0e1273
online, though it's not as complete.
>Alright how can I, without iterating through all nodes
>in the document, set the root element to have a
>default namespace and have that namespace propogate
>down to all children nodes which are not already
>namespaced - other than the special no-namespace?
You can't, any more than you can change the name of every element in
the document without iterating through it. As others have pointed
out, the namespace of an element is half of its extended name. Each
element has its own extended name, which is independent of other
elements in the document.
You are essentially asking for an API that treats namespaces as
merely artifacts of certain attributes. There have been such APIs,
notably SAX 1 and DOM 1. Namespace aware APIs such as SAX 2, DOM 2,
and JDOM have proven in practice much easier to use for documents
with namespaces.
--
Elliotte Rusty Harold
elharo at metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA
More information about the jdom-interest
mailing list