You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Erik Rydgren <er...@mandarinen.se> on 2001/06/13 16:49:22 UTC

Bug in nightly build 2001-06-11

Hi!

I was starting to get trouble when cloning documents. The symtoms was that
the order of attributes was changing and attribute values was disappearing.
Wierd? I think so :)
Tracked the sucker to the NamedNodeMapImpl::setNamedItemNS(NodeImpl *arg)
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.
Perhaps it could have been solved more efficient code wise, but not time
wise. For me that is ;)
I've seen that the problem is also present in the other implementations for
the NamedNodeMap but I haven't fixed them because I don't need them in my
project. The fix should be trivial when you have seen the solution for this
one.

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;
};


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org