1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-11 05:17:37 +03:00

xinclude: Don't remove root element

Don't replace include element at root with empty nodeset.
This commit is contained in:
Nick Wellnhofer 2024-06-17 21:06:46 +02:00
parent 860fb460ea
commit 1dd5e76a69
4 changed files with 25 additions and 9 deletions

View File

@ -1 +1,4 @@
<?xml version="1.0"?>
<doc>
</doc>

View File

@ -0,0 +1,6 @@
0 1 doc 0 0
1 14 #text 0 1
1 14 #text 0 1
0 15 doc 0 0

View File

@ -1,6 +1,8 @@
<?xml version="1.0"?>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="b.xml">
<xi:fallback><xi:include href="c.xml">
<xi:fallback/>
</xi:include></xi:fallback>
</xi:include>
<doc>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="b.xml">
<xi:fallback><xi:include href="c.xml">
<xi:fallback/>
</xi:include></xi:fallback>
</xi:include>
</doc>

View File

@ -1701,10 +1701,15 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
nb_elem++;
tmp = tmp->next;
}
if (nb_elem > 1) {
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_MULTIPLE_ROOT,
"XInclude error: would result in multiple root nodes\n",
NULL);
if (nb_elem != 1) {
if (nb_elem > 1)
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_MULTIPLE_ROOT,
"XInclude error: would result in multiple root "
"nodes\n", NULL);
else
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_MULTIPLE_ROOT,
"XInclude error: would result in no root "
"node\n", NULL);
xmlFreeNodeList(list);
return(-1);
}