[jdom-interest] The default namespace behaviour
clemahieu at gmail.com
Tue Jun 6 22:37:31 PDT 2006
I was hoping to mimic the behavior that XML files have. When using the
default namespace, all un-prefixed sub elements are within that namespace.
The b and c tags are in the "one" namespace.
If I changed this to:
The b and c tags are in the "two" namespace. I made one small change to a
and got a side-effect of changing b and c; this is how it works with written
If I parsed the first example and generated a JDOM model and called
a.setNamespace(Namespace.getNamespace("two")) and then spit the file out,
what I would have, essentially, is:
This doesn't fit the XML idea that, if you change the parent's namespace,
un-prefixed children will implicitly change their namespace.
Email: clemahieu at gmail.com
I strongly disagree with your sense that:
should set the namespace for all child elements that use the same default
namespace as a. This would be a big leap for JDOM to make. Since it's
entirely legitimate to have different default namespaces at different
levels, having JDOM guess which ones you wanted to change would invariably
be incorrect (in other words, what if I really wanted setNamespace() to just
set that element's namespace). Writing the getDescendents()-using code above
or even better, as Mr. Huffman suggested, a custom JDOMFactory would be the
best way to go about explictingly specifying what transformation you wanted
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest