[jdom-interest] Attribute namespace

Dennis Sosnoski dms at sosnoski.com
Thu Aug 16 18:07:14 PDT 2001

I've run into a problem with b7 and namespace handling. The situation is that I
want to add an attribute to an element with the attribute using the same
namespace as the element. I'm attempting to do this using code like:

    Namespace ns = element.getNamespace();
   element.addAttribute("name", "value", ns);

This appears to work okay when there's a prefix for the namespace, but when I
have an element like <gratuitous xmlns="http://www.gratuitous.org/a">... I get
an exception "org.jdom.IllegalNameException: The name "" is not legal for
JDOM/XML attribute namespaces: An attribute namespace without a prefix can only
be the NO_NAMESPACE namespace."

Am I doing something wrong here or is this a bug in the error checking?


  - Dennis

More information about the jdom-interest mailing list