[jdom-interest] Checking for attributes without namespace in
class Element
philip.nelson at omniresources.com
philip.nelson at omniresources.com
Thu Jun 28 07:50:55 PDT 2001
> I have just changed my code to work with JDOM beta 7R2.
> Everything works fine
> but the new setAttribute() method in Element.
> At the moment a checking for an already existing attribute
> happens only if the
> attribute uses a namespace prefix (see line 1603 in
> Element.java). I don't think
> that's sensible. In other words, you can't use setAttribute()
> to update an
> attributes value if you use no namespace prefix. You always
> need to check inside
> your code if an attribute already exists before you update its value.
The attribute is not updated, it is replaced. In the case of no namespace,
it can immediately be replaced. Otherwise there are xml namespace rules
like you can't have two elements with a prefix foo that point to different
uri's.
You can always update an attributes value without replacing it.
Attribute att = element.getAttribute("name");
att.setValue("boo");
More information about the jdom-interest
mailing list