Re: [xml] xmlAddChild behavior



On Tue, Feb 04, 2003 at 12:50:05AM -0500, Stefan Seefeld wrote:
hi there,

I'm reading the code for xmlAddChild, and I'm wondering
about what I read as a mismatch between docs and code:

The docs state:

* If the new node was already inserted in a document it is
* first unlinked from its existing context.

While the code reads:

     if (cur->doc != parent->doc) {
      xmlSetTreeDoc(cur, parent->doc);
     }

The small but important difference is that I interpreted 'unlink from
its existing context' as 'taking the node out of the document', while
the actual code only adjusts the doc pointer, if needed.
(I would have thought that xmlUnlinkNode is called...)

Would that be worth a clarification in the docs ?

  Right, good catch. Clarifying the doc seems the most sensible
option, adding xmlUnlinkNode(); is also possible but would change the
behaviour, and is probably not a good idea at this point.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]