mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-12 09:17:37 +03:00
xinclude: Expand includes in xmlXIncludeCopyNode
This should make nested includes work reliably. Fixes #424.
This commit is contained in:
parent
5e4b751f32
commit
bc267cb9bc
6
result/XInclude/issue424-1.xml
Normal file
6
result/XInclude/issue424-1.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
|
||||||
|
<p>Something</p>
|
||||||
|
<d><p>Something</p></d>
|
||||||
|
<d><p>Something</p></d>
|
||||||
|
</x>
|
6
result/XInclude/issue424-2.xml
Normal file
6
result/XInclude/issue424-2.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
|
||||||
|
<p>Something</p>
|
||||||
|
<d><p>Something</p></d>
|
||||||
|
<d><p>Something</p></d>
|
||||||
|
</x>
|
5
test/XInclude/without-reader/issue424-1.xml
Normal file
5
test/XInclude/without-reader/issue424-1.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
|
||||||
|
<p>Something</p>
|
||||||
|
<d><xinclude:include xpointer="xpointer(//p)"/></d>
|
||||||
|
<xinclude:include xpointer="xpointer(//d)"/>
|
||||||
|
</x>
|
5
test/XInclude/without-reader/issue424-2.xml
Normal file
5
test/XInclude/without-reader/issue424-2.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
|
||||||
|
<p>Something</p>
|
||||||
|
<xinclude:include xpointer="xpointer(//d)"/>
|
||||||
|
<d><xinclude:include xpointer="xpointer(//p)"/></d>
|
||||||
|
</x>
|
17
xinclude.c
17
xinclude.c
@ -91,6 +91,9 @@ struct _xmlXIncludeCtxt {
|
|||||||
unsigned long incTotal; /* total number of processed inclusions */
|
unsigned long incTotal; /* total number of processed inclusions */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static xmlXIncludeRefPtr
|
||||||
|
xmlXIncludeExpandNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr);
|
xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr);
|
||||||
|
|
||||||
@ -848,7 +851,19 @@ xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
if (elem->type == XML_DOCUMENT_NODE)
|
if (elem->type == XML_DOCUMENT_NODE)
|
||||||
result = xmlXIncludeCopyNodeList(ctxt, target, source, elem->children,
|
result = xmlXIncludeCopyNodeList(ctxt, target, source, elem->children,
|
||||||
NULL);
|
NULL);
|
||||||
else {
|
else if ((elem->type == XML_ELEMENT_NODE) &&
|
||||||
|
(elem->ns != NULL) &&
|
||||||
|
(xmlStrEqual(elem->name, XINCLUDE_NODE)) &&
|
||||||
|
((xmlStrEqual(elem->ns->href, XINCLUDE_NS)) ||
|
||||||
|
(xmlStrEqual(elem->ns->href, XINCLUDE_OLD_NS)))) {
|
||||||
|
xmlXIncludeRefPtr ref = xmlXIncludeExpandNode(ctxt, elem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Insert XML_XINCLUDE_START and XML_XINCLUDE_END nodes
|
||||||
|
*/
|
||||||
|
if ((ref != NULL) && (ref->inc != NULL))
|
||||||
|
result = xmlDocCopyNodeList(target, ref->inc);
|
||||||
|
} else {
|
||||||
result = xmlDocCopyNode(elem, target, 2);
|
result = xmlDocCopyNode(elem, target, 2);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user