[jdom-interest] XML best-practices Q, RE:getChildren(string,ns) w/ default namespace

Cory McIlroy cory at labfire.com
Thu Apr 18 12:48:16 PDT 2002

In my application I would like to pass around a jdom Element and have methods be
able to process the element.  This processing includes getting lists of children
elements of some name.

throughout the entire XML doc in question, i use one default namespace.  so, i
would like the various methods throughout the app to not have to worry about
getting children of a particular ns, because there is only one.

One way to do this is of course to just not use a ns in my XML doc.
and just use getChilren(String).  It would seem that this in some way violates
good xml technique by using no_namespace.  

If I do us a default ns, then i have to get it from the doc and pass it, the
default ns, around with the element so that the methods can say

Or, to get around passing around the defaultNS, I could get the ns of the
element that gets passed in to the method

This assumes that the ns of the element is the same as its children.  This is
true in this application, but it seems inelegant.  This method is similar to
the behavior of getChildren(String) that some have talked about on this list
wherein it would return all children that are not explicitly declared as
belonging to a different ns than the parents'.  Is this generally regarded as

I feel like perhaps I am missing a big-picture issue, so I posted to get
thoughts from more experienced jdom users.


More information about the jdom-interest mailing list