[jdom-interest] Default Namespace vs No-Namespace.

Robert (Jamie) Munro rjmunro at arjam.net
Fri Jul 4 04:03:19 PDT 2003


> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of John Jefferson
> Sent: 04 July 2003 01:10
> To: Jason Hunter
> Cc: Elliotte Rusty Harold; 'jdom-interest at jdom.org'
> Subject: Re: [jdom-interest] Default Namespace vs No-Namespace.
>
>
> Thanks for all the dialog!!, I think I have a good
> unstanding of the situation now.
>
> Basicially the design decision that all elements know
> which namespace they belong to at all times prevents
> you from using some features of namespace inheritance?
>
>
> I mean, forgetting how jdom works for a moment, if I
> have a document with no namespacing and then I want to
> make all elements adher to a namespace then all that I
> have to do is add xmlns="mynamespace" to the root
> element using a text editor and all children will then
> inherit this namespace.

This is only true if your document has no existing namespace related stuff
at all. If it has various random elements that are explicitly declared to be
in the null namespace (i.e. xmlns=""), it is an identical document, and must
be treated identically according to the latest XML specifications. Your edit
of it would not work.

Bearing in mind that JDOM is about moving elements from one place to
another, there are only two ways it could proceed. Either it could keep the
fact that a namespace was not specifically declared on an element at all
times, and when it moved it to another document, it would become a
completely different element, that had no relationship at all to the
original, and is not likely to be correct - this is analogous to changing
the elements name - or it could keep elements as they are. When an element
is created, if you know what name it is going to have, you know what
namespace it is in. If it is in another namespace, it is not the same
element.

A namespace is like a person's surname*. In the phone book, it is acceptable
for it to have a heading "Munro", and then put Robert, Colin, Ruth, and all
the other people called Munro, one after another. Another phone book could
then have a heading "Jefferson", and have John and all your relatives listed
there. You might also have people with no surname, like Madonna. If I was to
load the phone book into a database, I would have to read these headings,
and populate my database as:

Robert Munro
Colin Munro
Ruth Munro
John Jefferson
Madonna

Not as:
Surname: "Munro"
Robert
Colin
Ruth
Surname: "Jefferson"
John
Madonna

because if I did the second, look what has happened to Madonna - She's
suddenly Madonna Jefferson, who is a completely different person (an obscure
relative of yours presumably), rather than the International Rock star we
all know and love. This is pretty similar to what you are arguing for. What
JDOM is outputting in the above case is:

Surname: "Munro"
Robert
Colin
Ruth
Surname: "Jefferson"
John
Surname: ""
Madonna


Robert Munro

* note that for this analogy to work, we'll assume people can't have the
same first name and surname, but they can have either the same first name or
the same surname




More information about the jdom-interest mailing list