/** * Get this AttributeMap in sync with the given "defaults" map. * @param defaults The default attributes map to sync with. */ void DOMAttrMapImpl::reconcileDefaultAttributes(const DOMAttrMapImpl* defaults) { // remove any existing default XMLSize_t nsize = getLength(); for (XMLSSize_t i = nsize - 1; i >= 0; i--) { DOMAttr* attr = (DOMAttr*)item(i); if (!attr->getSpecified()) { removeNamedItemAt(i); } } hasDefaults(false); // add the new defaults if (defaults) { hasDefaults(true); if (nsize == 0) { cloneContent(defaults); } else { XMLSize_t dsize = defaults->getLength(); for (XMLSize_t n = 0; n < dsize; n++) { DOMAttr* attr = (DOMAttr*)defaults->item(n); DOMAttr* newAttr = (DOMAttr*)attr->cloneNode(true); setNamedItemNS(newAttr); DOMAttrImpl* newAttrImpl = (DOMAttrImpl*) newAttr; newAttrImpl->setSpecified(false); } } } } // reconcileDefaults()
AttrMapImpl::AttrMapImpl(NodeImpl *ownerNod, NamedNodeMapImpl *defaults) : NamedNodeMapImpl(ownerNod) { hasDefaults(false); if (defaults != null) { if (defaults->getLength() > 0) { hasDefaults(true); cloneContent(defaults); } } }
DOMAttrMapImpl::DOMAttrMapImpl(DOMNode *ownerNod, const DOMNamedNodeMapImpl *defaults) : DOMNamedNodeMapImpl(ownerNod) { hasDefaults(false); if (defaults != 0) { if (defaults->getLength() > 0) { hasDefaults(true); cloneContent(defaults); } } }
DOMAttrMapImpl::DOMAttrMapImpl(DOMNode *ownerNod, const DOMAttrMapImpl *defaults) { this->fOwnerNode=ownerNod; this->fNodes = 0; hasDefaults(false); if (defaults != 0) { if (defaults->getLength() > 0) { hasDefaults(true); cloneContent(defaults); } } }
DOMNode *DOMAttrMapImpl::removeNamedItemNS(const XMLCh *namespaceURI, const XMLCh *localName) { if (this->readOnly()) throw DOMException( DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager); int i = findNamePoint(namespaceURI, localName); if (i < 0) throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMNamedNodeMapMemoryManager); DOMNode * removed = fNodes -> elementAt(i); fNodes -> removeElementAt(i); //remove n from nodes castToNodeImpl(removed)->fOwnerNode = fOwnerNode->getOwnerDocument(); castToNodeImpl(removed)->isOwned(false); // Replace it if it had a default value // (DOM spec level 2 - Element Interface) if (hasDefaults() && (removed != 0)) { DOMAttrMapImpl* defAttrs = ((DOMElementImpl*)fOwnerNode)->getDefaultAttributes(); DOMAttr* attr = (DOMAttr*)(defAttrs->getNamedItemNS(namespaceURI, localName)); if (attr != 0) { DOMAttr* newAttr = (DOMAttr*)attr->cloneNode(true); setNamedItemNS(newAttr); } } return removed; }
XERCES_CPP_NAMESPACE_BEGIN DOMAttrMapImpl::DOMAttrMapImpl(DOMNode *ownerNod) : DOMNamedNodeMapImpl(ownerNod) { hasDefaults(false); }
// 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; }
XERCES_CPP_NAMESPACE_BEGIN DOMAttrMapImpl::DOMAttrMapImpl(DOMNode *ownerNod) { this->fOwnerNode=ownerNod; this->fNodes = 0; hasDefaults(false); }
XERCES_CPP_NAMESPACE_BEGIN AttrMapImpl::AttrMapImpl(NodeImpl *ownerNod) : NamedNodeMapImpl(ownerNod) { hasDefaults(false); }
DOMNode *DOMAttrMapImpl::removeNamedItem(const XMLCh *name) { DOMNode* removed = DOMNamedNodeMapImpl::removeNamedItem(name); // Replace it if it had a default value // (DOM spec level 1 - Element Interface) if (hasDefaults() && (removed != 0)) { DOMAttrMapImpl* defAttrs = ((DOMElementImpl*)fOwnerNode)->getDefaultAttributes(); DOMAttr* attr = (DOMAttr*)(defAttrs->getNamedItem(name)); if (attr != 0) { DOMAttr* newAttr = (DOMAttr*)attr->cloneNode(true); setNamedItem(newAttr); } } return removed; }
NodeImpl *AttrMapImpl::removeNamedItemNS(const DOMString &namespaceURI, const DOMString &localName) { NodeImpl* removed = NamedNodeMapImpl::removeNamedItemNS(namespaceURI, localName); // Replace it if it had a default value // (DOM spec level 2 - Element Interface) if (hasDefaults() && (removed != null)) { AttrMapImpl* defAttrs = ((ElementImpl*)ownerNode)->getDefaultAttributes(); AttrImpl* attr = (AttrImpl*)(defAttrs->getNamedItemNS(namespaceURI, localName)); if (attr != null) { AttrImpl* newAttr = (AttrImpl*)attr->cloneNode(true); setNamedItem(newAttr); } } return removed; }
// remove the name using index // avoid calling findNamePoint again if the index is already known DOMNode * DOMAttrMapImpl::removeNamedItemAt(XMLSize_t index) { if (this->readOnly()) throw DOMException( DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager); DOMNode *removed = item(index); if(!removed) throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMNamedNodeMapMemoryManager); fNodes->removeElementAt(index); castToNodeImpl(removed)->fOwnerNode = fOwnerNode->getOwnerDocument(); castToNodeImpl(removed)->isOwned(false); // 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; }