diff options
Diffstat (limited to 'xinclude.c')
-rw-r--r-- | xinclude.c | 65 |
1 files changed, 45 insertions, 20 deletions
@@ -1459,6 +1459,16 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { return(-1); } ctxt->incTab[nr]->doc = doc; + /* + * It's possible that the requested URL has been mapped to a + * completely different location (e.g. through a catalog entry). + * To check for this, we compare the URL with that of the doc + * and change it if they disagree (bug 146988). + */ + if (!xmlStrEqual(URL, doc->URL)) { + xmlFree(URL); + URL = xmlStrdup(doc->URL); + } for (i = nr + 1; i < ctxt->incNr; i++) { if (xmlStrEqual(URL, ctxt->incTab[i]->URI)) { ctxt->incTab[nr]->count++; @@ -2106,28 +2116,43 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) { } } - /* - * Change the current node as an XInclude start one, and add an - * entity end one - */ - cur->type = XML_XINCLUDE_START; - end = xmlNewNode(cur->ns, cur->name); - if (end == NULL) { - xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_BUILD_FAILED, - "failed to build node\n", NULL); - return(-1); - } - end->type = XML_XINCLUDE_END; - xmlAddNextSibling(cur, end); + if (ctxt->parseFlags & XML_PARSE_NOXINCNODE) { + /* + * Add the list of nodes + */ + while (list != NULL) { + end = list; + list = list->next; - /* - * Add the list of nodes - */ - while (list != NULL) { - cur = list; - list = list->next; + xmlAddPrevSibling(cur, end); + } + xmlUnlinkNode(cur); + xmlFreeNode(cur); + } else { + /* + * Change the current node as an XInclude start one, and add an + * XInclude end one + */ + cur->type = XML_XINCLUDE_START; + end = xmlNewNode(cur->ns, cur->name); + if (end == NULL) { + xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, + XML_XINCLUDE_BUILD_FAILED, + "failed to build node\n", NULL); + return(-1); + } + end->type = XML_XINCLUDE_END; + xmlAddNextSibling(cur, end); - xmlAddPrevSibling(end, cur); + /* + * Add the list of nodes + */ + while (list != NULL) { + cur = list; + list = list->next; + + xmlAddPrevSibling(end, cur); + } } |