/** * Removes the specified attribute node. * * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr) */ public Attr removeAttributeNode(Attr oldAttr) throws DOMException { if (isReadonly()) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); } if (this.attributes == null || this.attributes.getNamedItem(oldAttr.getName()) == null) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null); throw new DOMException(DOMException.NOT_FOUND_ERR, msg); } return (AttrImpl) this.attributes.removeNamedItem(oldAttr .getName()); }
/** * Removes an attribute by name. * * @param name The name of the attribute to remove * @see org.w3c.dom.Element#removeAttribute(String) */ public void removeAttribute(String name) throws DOMException { if (this.isReadonly()) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null); throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg); } if (name.startsWith(OMConstants.XMLNS_NS_PREFIX)) { String namespacePrefix = DOMUtil.getLocalName(name); if (this.findNamespaceURI(namespacePrefix) != null) { this.removeNamespace(namespacePrefix); } } if (this.attributes != null) { this.attributes.removeNamedItem(name); } }