[jdom-interest] RE: add attributes

elephantwalker elephantwalker at home.com
Sat Mar 24 18:26:27 PST 2001


I spoke too soon. The first idiom does *not* work. I may have left out a few
details also. e was an element without a parent. It appears that
e.addAttribute(new Attribute(  )) doesn't really work without a parent.

This works:

                 e.removeAttribute("id");
                 e.addAttribute("id",id);

but if I leave out the removeAttribute, it doesn't work. The other comments
still apply.

-----Original Message-----
From: elephantwalker [mailto:elephantwalker at home.com]
Sent: Saturday, March 24, 2001 5:38 PM
To: jdom-interest at jdom.com
Subject: add attributes


This works...

e.removeAttribute("id",e.getNamespace());
e.addAttribute(new Attribute("id",someid));

This doesn't...

e.addAttribute(new Attribute("id",someid));

this message is returned:

org.jdom.IllegalAddException: The attribute "id" could not be added to the
element "g": Duplicate attributes are not allowed

The docs indicate that the replacement logic needs to be done, so this could
be just a "feature" and development issue. Any hints on this?

Regards,

Elephantwalker







More information about the jdom-interest mailing list