Skip to content
Snippets Groups Projects
Commit 6f9ea6d7 authored by Tinny Ng's avatar Tinny Ng
Browse files

DOM: add removeNamedItemAt to DOMAttrMapImpl

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174025 13f79535-47bb-0310-9956-ffa450edef68
parent 521b1a48
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,35 @@ DOMNode *DOMAttrMapImpl::removeNamedItemNS(const XMLCh *namespaceURI, const XMLC
return removed;
}
// remove the name using index
// avoid calling findNamePoint again if the index is already known
DOMNode * DOMAttrMapImpl::removeNamedItemAt(XMLSize_t index)
{
DOMNode* removed = DOMNamedNodeMapImpl::removeNamedItemAt(index);
// Replace it if it had a default value
// (DOM spec level 1 - Element Interface)
if (hasDefaults() && (removed != 0))
{
DOMAttrMapImpl* defAttrs = ((DOMElementImpl*)fOwnerNode)->getDefaultAttributes();
const XMLCh* localName = removed->getLocalName();
DOMAttr* attr = 0;
if (localName)
attr = (DOMAttr*)(defAttrs->getNamedItemNS(removed->getNamespaceURI(), localName));
else
attr = (DOMAttr*)(defAttrs->getNamedItem(((DOMAttr*)removed)->getName()));
if (attr != 0)
{
DOMAttr* newAttr = (DOMAttr*)attr->cloneNode(true);
setNamedItem(newAttr);
}
}
return removed;
}
/**
* Get this AttributeMap in sync with the given "defaults" map.
* @param defaults The default attributes map to sync with.
......
......@@ -98,6 +98,7 @@ public:
virtual DOMNode *removeNamedItem(const XMLCh *name);
virtual DOMNode *removeNamedItemNS(const XMLCh *namespaceURI, const XMLCh *localName);
virtual DOMNode *removeNamedItemAt(XMLSize_t index);
void reconcileDefaultAttributes(const DOMAttrMapImpl* defaults);
void moveSpecifiedAttributes(DOMAttrMapImpl* srcmap);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment