[jdom-interest] Namespace issues, et al.
Bradley S. Huffman
hip at a.cs.okstate.edu
Mon Feb 24 08:58:28 PST 2003
Philip Nelson writes:
> The simple story is, you must always provide the namespace for the node or
> JDOM will assume it's in the no namespace namespace. Remember that and it
> will always do what you expect on output.
I'd go even furhter and suggest people not use any of methods that default
to no namespace. Instead always specify a namespace even if it is
Namespace.NO_NAMESPACE.
static Namespace DEFAULTNS = Namespace.NO_NAMESPACE;
static Namespace NS1 = Namespace.getNamespace("www.ns1.org");
static Namespace NS2 = Namespace.getNamespace("www.ns2.org");
Element e0 = new Element("test", DEFAULTNS);
Element e1 = new Element("foo", NS1);
Element child = root.getChild("bar", NS2);
Element child = root.getChild("boo", DEFAULTNS);
Brad
More information about the jdom-interest
mailing list