[jdom-interest] First pass at Namespace revision[eg]
jhunter at collab.net
Mon Apr 2 14:50:26 PDT 2001
"Rosen, Alex" wrote:
> I'm much less concerned about changing the namespace of an element as I am
> about creating or finding elements in namespaces. When parsing a tree like:
> <element xmlns="http://foo">
> <child1 />
> <child2 />
> I think it's perfectly natural to want to call getChild("child1"), but this
> will return null. And trying to create this tree with new Element("child1") and
> have it come out wrong. This will lead to confusion.
Note that the default namespace is basically just a namespace with an
empty string prefix. So a change like you suggest would also mean that
for a tree like:
Your proposal to have getChild() very depending on the namespace of the
element called on would have elt.getChild("child1") return <x:child1/>
instead of the true <child1/>. That's nasty.
> I don't want to push on a decision that was made a long time ago, before I got
> here, that would require rewriting a lot of code. With the existing API, I
> think we should add a warning to the Element JavaDoc explaining how namespaces
> are handled in JDOM. I'd be willing to try to come up with the wording.
Sure, feel free. People need to recognize the default namespace is NOT
"the namespace when no other namespaces are in effect".
More information about the jdom-interest