}
}
fireUserDataHandlers(UserDataHandler.NODE_RENAMED, n, e);
if (getEventsEnabled()) {
MutationNameEvent ev =
(MutationNameEvent) createEvent("MutationNameEvent");
ev.initMutationNameEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMElementNameChanged",
true, // canBubbleArg
false, // cancelableArg
null, // relatedNodeArg
prevNamespaceURI,
prevNodeName);
dispatchEvent(ev);
}
return e;
} else {
if (n instanceof AbstractAttrNS) {
AbstractAttrNS a = (AbstractAttrNS) n;
Element e = a.getOwnerElement();
// Remove attribute from element
if (e != null) {
e.removeAttributeNode(a);
}
// Update name
a.namespaceURI = ns;
a.nodeName = qn;
// Reinsert attribute into element
if (e != null) {
e.setAttributeNodeNS(a);
}
fireUserDataHandlers(UserDataHandler.NODE_RENAMED, a, null);
if (getEventsEnabled()) {
MutationNameEvent ev =
(MutationNameEvent) createEvent("MutationNameEvent");
ev.initMutationNameEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMAttrNameChanged",
true, // canBubbleArg
false, // cancelableArg
a, // relatedNodeArg
prevNamespaceURI,
prevNodeName);
dispatchEvent(ev);
}
return a;
} else {
AbstractAttr a = (AbstractAttr) n;
Element e = a.getOwnerElement();
// Remove attribute from element and create new one
if (e != null) {
e.removeAttributeNode(a);
}
AbstractAttr a2 = (AbstractAttr) createAttributeNS(ns, qn);
// Move attribute value across
a2.setNodeValue(a.getNodeValue());
// Move user data across
a2.userData = a.userData == null
? null
: (HashMap) a.userData.clone();
a2.userDataHandlers = a.userDataHandlers == null
? null
: (HashMap) a.userDataHandlers.clone();
// Reinsert attribute into parent
if (e != null) {
e.setAttributeNodeNS(a2);
}
fireUserDataHandlers(UserDataHandler.NODE_RENAMED, a, a2);
if (getEventsEnabled()) {
MutationNameEvent ev
= (MutationNameEvent) createEvent("MutationNameEvent");
ev.initMutationNameEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMAttrNameChanged",
true, // canBubbleArg
false, // cancelableArg
a2, // relatedNodeArg
prevNamespaceURI,