http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2174 *** shadow/2174 Thu Jun 14 01:22:18 2001 --- shadow/2174.tmp.18376 Thu Jun 14 01:22:18 2001 *************** *** 0 **** --- 1,70 ---- + +============================================================================+ + | Bug in NamedNodeMapImpl | + +----------------------------------------------------------------------------+ + | Bug #: 2174 Product: Xerces-C | + | Status: NEW Version: Nightly build | + | Resolution: Platform: All | + | Severity: Major OS/Version: All | + | Priority: Other Component: DOM | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + I was gettin trouble when cloning documents. After a clone the NamedNodeMapImpl + of attributes to some elements was sorted in the wrong order. The code relies + on the NamedNodeMap to be sorted in nodeName order to be able to use efficient + search methods. Tracked the bug to the NamedNodeMapImpl::setNamedItemNS method. + The error was that the findNamePoint method for namespaces never returns + other then -1 when the node is not found. The method for finding nodes by + node name returns a negative number for the index where to insert the node + to keep things sorted. I changed the code for the NamedNodeMapImpl as shown + at the bottom and my system started to work again. + I've seen that the problem is also present in the other implementations for + the NamedNodeMap + + Regards + Erik Rydgren + Mandarinen systems AB + Sweden + + ---------------------------------------------------------------------------- + -------------------------------- + NodeImpl * NamedNodeMapImpl::setNamedItemNS(NodeImpl *arg) + { + if (arg->getOwnerDocument() != ownerNode->getOwnerDocument()) + throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR,null); + if (readOnly) + throw + DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); + if (arg->isOwned()) + throw DOM_DOMException(DOM_DOMException::INUSE_ATTRIBUTE_ERR,null); + + arg->ownerNode = ownerNode; + arg->isOwned(true); + int i=findNamePoint(arg->getNamespaceURI(), arg->getLocalName()); + NodeImpl *previous=null; + if(i>=0) { + previous = nodes->elementAt(i); + nodes->setElementAt(arg,i); + } else { + >>> START CHANGED CODE + i=findNamePoint(arg->getNodeName()); // Insert point (may be end of + list) + if (i<0) + i = -1 - i; + >>> END CHANGED CODE + if(null==nodes) + nodes=new NodeVector(); + nodes->insertElementAt(arg,i); + } + if (previous != null) { + previous->ownerNode = ownerNode->getOwnerDocument(); + previous->isOwned(false); + } + + return previous; + }; \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
