[jdom-interest] getChild and namespace

elephantwalker elephantwalker at home.com
Sat Mar 24 16:40:25 PST 2001

I'm a little confused about something.

If you have a default namespace (usually the name of the dtd without the
.dtd extension), and there are other namespaces declared in the root element
of your document....

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
<svg  xmlns:a="http://www.adobe.com/svg10-extensions"
    <symbol id="rectangle" >
    <path  d="M0,0L0,50L50,50L0,0z" />
    <use xlink:href="#rectangle" />

If you do a doc.getRootElement(), and then get the Namespace it is the path
to the dtd without the dtd extension. If you do a root.getChild("defs"), the
return is null, but if you do root.getChild("defs",root.getNamespace()), you
get the symbol element.

I am sorry, but how can that be a practical implementation? Its not very
polymorthic. That is, jdom code written for xml with no namespace's should
work the same as code written for the default namespace. It makes the
getChild("name") method almost useless, because any minor change in the xml
document over time will almost certainly include new namespaces, but the
presense of a default namespace will not change.

If I have "glorcked" to much here, and this is just a bug...




More information about the jdom-interest mailing list