summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2019-02-06 22:46:57 +0100
committerStefan Behnel <stefan_ml@behnel.de>2019-02-06 22:46:57 +0100
commitee9dc101d7190c24d5b72ba208412c82e5c7484b (patch)
tree301ce3dd346ca061bfb83c200685a9781498a31b
parent3a8123d0115e8ed555dc1d699aab05ec67be61ed (diff)
downloadpython-lxml-ee9dc101d7190c24d5b72ba208412c82e5c7484b.tar.gz
Also set .doc field of attribute children (if any) during subtree migration.
-rw-r--r--src/lxml/proxy.pxi8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lxml/proxy.pxi b/src/lxml/proxy.pxi
index 2a365f6b..fd00bb68 100644
--- a/src/lxml/proxy.pxi
+++ b/src/lxml/proxy.pxi
@@ -369,6 +369,7 @@ cdef int moveNodeToDocument(_Document doc, xmlDoc* c_source_doc,
tree.xmlRemoveID(c_source_doc, c_attr)
# set C doc link also for attributes
c_node.doc = c_doc
+ _fixDocChildren(c_node.children, c_doc)
c_node = c_node.next
tree.END_FOR_EACH_FROM(c_element)
@@ -401,6 +402,13 @@ cdef int moveNodeToDocument(_Document doc, xmlDoc* c_source_doc,
return 0
+cdef inline void _fixDocChildren(xmlNode* c_child, xmlDoc* c_doc):
+ while c_child:
+ c_child.doc = c_doc
+ _fixDocChildren(c_child.children, c_doc)
+ c_child = c_child.next
+
+
cdef int _fixCNs(_Document doc, xmlNode* c_start_node, xmlNode* c_node,
_nscache* c_ns_cache, xmlNs* c_del_ns_list) except -1:
cdef xmlNs* c_ns = NULL