[LIBXML2] Update to v2.9.3.
[reactos.git] / reactos / lib / 3rdparty / libxml2 / tree.c
index 307782c..6a158ce 100644 (file)
@@ -1451,9 +1451,9 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
        node->content = xmlBufDetach(buf);
 
        if (last == NULL) {
-           last = ret = node;
+           ret = node;
        } else {
-           last = xmlAddNextSibling(last, node);
+           xmlAddNextSibling(last, node);
        }
     } else if (ret == NULL) {
         ret = xmlNewDocText(doc, BAD_CAST "");
@@ -1639,9 +1639,9 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
        node->content = xmlBufDetach(buf);
 
        if (last == NULL) {
-           last = ret = node;
+           ret = node;
        } else {
-           last = xmlAddNextSibling(last, node);
+           xmlAddNextSibling(last, node);
        }
     }
 
@@ -2799,8 +2799,27 @@ xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
        if(tree->type == XML_ELEMENT_NODE) {
            prop = tree->properties;
            while (prop != NULL) {
+                if (prop->atype == XML_ATTRIBUTE_ID) {
+                    xmlRemoveID(tree->doc, prop);
+                }
+
                prop->doc = doc;
                xmlSetListDoc(prop->children, doc);
+
+                /*
+                 * TODO: ID attributes should be also added to the new
+                 * document, but this breaks things like xmlReplaceNode.
+                 * The underlying problem is that xmlRemoveID is only called
+                 * if a node is destroyed, not if it's unlinked.
+                 */
+#if 0
+                if (xmlIsID(doc, tree, prop)) {
+                    xmlChar *idVal = xmlNodeListGetString(doc, prop->children,
+                                                          1);
+                    xmlAddID(NULL, doc, idVal, prop);
+                }
+#endif
+
                prop = prop->next;
            }
        }