[jdom-interest] getChild and namespace

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Mar 27 11:41:16 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"
> "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303
> -stylable.dtd"
> >
> <svg  xmlns:a="http://www.adobe.com/svg10-extensions"
> a:timeline="independent">
>   <defs>
>     <symbol id="rectangle" >
>     <path  d="M0,0L0,50L50,50L0,0z" />
>     </symbol>
>   </defs>
>   <g>
>     <use xlink:href="#rectangle" />
>   </g>
> </svg>
> If you do a doc.getRootElement(), and then get the Namespace 
> it is the path
> to the dtd without the dtd extension. 

I can't even parse this.  I get a StringIndexOutOfBounds exception from
xerces (ver 1.2).  I tried another svg example and the same thing happened.
what parser are you using?

When I try to create my own doctype in a similar fashion but without
including the entities that svg is including in the dtd, I end up with a
NO_NAMESPACE namespace so i don't think that the doctype declaration has
anything to do with a default namespace uri of "svg".  I have to think I've
completely missed the boat on your explanation but that wouldn't even be a
valid uri.

> 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.

What!!!  This is why I spent the time with this because this would be a
serious problem, no?

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

I hope not too...

More information about the jdom-interest mailing list