mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-25 23:21:26 +03:00
xinclude: Make xmlXIncludeCopyNode return a node list
Convert callers of xmlXIncludeCopyNode to handle node lists.
This commit is contained in:
parent
64eaf4d429
commit
5e4b751f32
38
xinclude.c
38
xinclude.c
@ -831,7 +831,9 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
* @elem: the element
|
* @elem: the element
|
||||||
*
|
*
|
||||||
* Make a copy of the node while preserving the XInclude semantic
|
* Make a copy of the node while preserving the XInclude semantic
|
||||||
* of the Infoset copy
|
* of the Infoset copy.
|
||||||
|
*
|
||||||
|
* Returns a node list, not a single node.
|
||||||
*/
|
*/
|
||||||
static xmlNodePtr
|
static xmlNodePtr
|
||||||
xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
||||||
@ -878,7 +880,7 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
cur = elem;
|
cur = elem;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
res = xmlXIncludeCopyNode(ctxt, target, source, cur);
|
res = xmlXIncludeCopyNode(ctxt, target, source, cur);
|
||||||
if (res != NULL) {
|
while (res != NULL) {
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
result = last = res;
|
result = last = res;
|
||||||
} else {
|
} else {
|
||||||
@ -887,6 +889,7 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
last = res;
|
last = res;
|
||||||
}
|
}
|
||||||
res->parent = parent;
|
res->parent = parent;
|
||||||
|
res = res->next;
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
@ -1151,7 +1154,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
static xmlNodePtr
|
static xmlNodePtr
|
||||||
xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
||||||
xmlDocPtr source, xmlXPathObjectPtr obj) {
|
xmlDocPtr source, xmlXPathObjectPtr obj) {
|
||||||
xmlNodePtr list = NULL, last = NULL;
|
xmlNodePtr list = NULL, last = NULL, copy;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (source == NULL)
|
if (source == NULL)
|
||||||
@ -1191,16 +1194,27 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
case XML_ENTITY_DECL:
|
case XML_ENTITY_DECL:
|
||||||
continue; /* for */
|
continue; /* for */
|
||||||
}
|
}
|
||||||
if (last == NULL)
|
/*
|
||||||
list = last = xmlXIncludeCopyNode(ctxt, target, source,
|
* OPTIMIZE TODO: External documents should already be
|
||||||
set->nodeTab[i]);
|
* expanded, so xmlDocCopyNode should work as well.
|
||||||
else {
|
* xmlXIncludeCopyNode is only required for the initial
|
||||||
xmlAddNextSibling(last,
|
* document.
|
||||||
xmlXIncludeCopyNode(ctxt, target, source,
|
*/
|
||||||
set->nodeTab[i]));
|
copy = xmlXIncludeCopyNode(ctxt, target, source,
|
||||||
if (last->next != NULL)
|
set->nodeTab[i]);
|
||||||
last = last->next;
|
if (copy == NULL) {
|
||||||
|
xmlFreeNodeList(list);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
if (last == NULL) {
|
||||||
|
list = copy;
|
||||||
|
} else {
|
||||||
|
while (last->next != NULL)
|
||||||
|
last = last->next;
|
||||||
|
copy->prev = last;
|
||||||
|
last->next = copy;
|
||||||
}
|
}
|
||||||
|
last = copy;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user