[jdom-interest] Namespace inheritance after cloning
jhunter at xquery.com
Sun Nov 28 10:51:45 PST 2004
> I see what you're saying about elements in different documents having no
> connection. I've been thinking too much in OOP!
That's why we have a FAQ entry on it. People sometimes think moving
elements in JDOM is like copy/pasting their serialized XML form. But
that's not how it works in JDOM (or XQuery for that matter).
> Although I'm adding <next> to <root>, as far as JDOM is concerned, it
> could be in any namespace, so if it doesn't have one, it bungs it in the
> empty one.
When you create an element without a namespace it's in *no* namespace,
not any namespace.
> I thought there wasn't a "default" namespace in XML. xmlns="" (no
> namespace) is different from "default" namespace.
There is a default namespace, which more properly could be called the
"no prefix namespace". xmlns="" sets the default namespace to no
namespace for the scope of that element.
> I expected JDOM to allow <next> to inherit it's new parent's namespace if
> it didn't explicity define one. Wrong mental model for me :)
> I don't suppose it's really an issue for most but I was also thinking of
> bandwidth. If I have to explicitly define namespaces for each element,
> that comes from a different Document, then the finished Document will have
> tons of namespace "noise" in it. I'll think about that though.
Namespaces are an intrinsic part of an element. A furniture store
<table> doesn't become an XHTML <table> just because you moved it to an
More information about the jdom-interest