/** * Returns the namespace uri, given the prefix. If it is not found at this element, searches the * parent. * * @param prefix * @return Returns namespace. */ public String getNamespaceURI(String prefix) { OMNamespace ns = this.findNamespaceURI(prefix); return (ns != null) ? ns.getNamespaceURI() : null; }
/** * Retrieves an attribute node by local name and namespace URI. * * @see org.w3c.dom.Element#getAttributeNodeNS(String, String) */ public Attr getAttributeNodeNS(String namespaceURI, String localName) { if (OMConstants.XMLNS_NS_URI.equals(namespaceURI)) { OMNamespace ns = this.findNamespaceURI(localName); String nsuri = ns != null ? ns.getNamespaceURI() : ""; AttrImpl namespaceAttr = new AttrImpl(this.ownerNode, localName, nsuri, this.factory); NamespaceImpl xmlNs = new NamespaceImpl(OMConstants.XMLNS_NS_URI); namespaceAttr.setOMNamespace(xmlNs); return namespaceAttr; } return (this.attributes == null) ? null : (Attr) this.attributes .getNamedItemNS(namespaceURI, localName); }
/** * 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); } }