[jdom-interest] JDOM namespace bug?

Jason Hunter jhunter at collab.net
Wed Apr 11 15:22:16 PDT 2001


> Here's a sample XML instance file:
> <?xml version="1.0" encoding="UTF-8"?>
> <ej:baz xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xmlns:ej=""
> xmlns="http://www.w3.org/1999/xhtml">
>         <ej:foo>1 <b>2 3</b> 4 <b>5</b> 6 <b>7</b> 8 9 10 <b>11</b> 12
> </ej:foo>
> </ej:baz>
> 
>   A call to elt.getNamespace().getPrefix() returns the
> empty String on both <ej:foo/> and <b/>. I expected
> it to return "ej" when called on <ej:foo/>. Please see
> my previous post for more detail.
> 
> -brian

Here's what I get parsing that file with the latest code from CVS:

% java Tester2 baz.xml
Exception in thread "main" org.jdom.JDOMException: Error in building:
The name "" is not legal for JDOM/XML namespaces: Namespace URIs must be
non-null and non-empty Strings.

This is what you should see, an error msg that xmlns:ej="" isn't legal. 
If you read the spec carefully, only a default namespace may have an
empty attribute value.  This extent of namespace sanity checking is
relatively new, so your code is just misbehaving because assumptions
were violated.  Now we check up front.

-jh-



More information about the jdom-interest mailing list