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 Benoit Lefevre <be...@effix.fr> on 2001/06/13 10:42:23 UTC

DOM_Element creation probleme.


Hello.

     Here is my probleme : during my use of DOM part of Xerces, i'd like to create a
     DOM_Element witch is in some kind of "stand by" state.

     I mean by "stand by" that i'd like to build a DOM_Element like this:

          DOM_Element anElement = createDocument().createElement(DOMString("A_Tag"));

     And use it later in another DOM_Document.

     To sum it up i'd like to know if there is relation between the DOM_Document objects and it
     Elements that disable the use the above code line or if it is valide to do this to create a
     independant DOM_Element ?

Thanks in advence.

Benoit Lefevre.



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


Bug in nightly build 2001-06-11

Posted by Erik Rydgren <er...@mandarinen.se>.
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


RE: DOM_Element creation probleme.

Posted by Erik Rydgren <er...@mandarinen.se>.
Yes this is legal. You can then later use import node to use it in another
document.

Erik Rydgren
Mandarinen Systems AB
Sweden

-----Original Message-----
From: Benoit Lefevre [mailto:benoit.lefevre@effix.fr]
Sent: den 13 juni 2001 10:42
To: xerces-c-dev@xml.apache.org
Subject: DOM_Element creation probleme.




Hello.

     Here is my probleme : during my use of DOM part of Xerces, i'd like to
create a
     DOM_Element witch is in some kind of "stand by" state.

     I mean by "stand by" that i'd like to build a DOM_Element like this:

          DOM_Element anElement =
createDocument().createElement(DOMString("A_Tag"));

     And use it later in another DOM_Document.

     To sum it up i'd like to know if there is relation between the
DOM_Document objects and it
     Elements that disable the use the above code line or if it is valide to
do this to create a
     independant DOM_Element ?

Thanks in advence.

Benoit Lefevre.



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


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