diff options
author | Mike Hommey <mh@glandium.org> | 2004-10-28 09:07:41 +0000 |
---|---|---|
committer | Mike Hommey <mh@glandium.org> | 2004-10-28 09:07:41 +0000 |
commit | 9705f1a5e858108d21a0128556f42b25d16833cd (patch) | |
tree | f819e7482d433f8bf5da005695c79189dd5ce527 /error.c | |
parent | 0732be88d054db33fa0ca479eab9988c8e6be42e (diff) | |
download | libxml2-upstream/2.6.15.tar.gz |
Load /tmp/tmp.SgII7T/libxml2-2.6.15 intoupstream/2.6.15
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 40 |
1 files changed, 32 insertions, 8 deletions
@@ -447,13 +447,13 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel, char *str = NULL; xmlParserInputPtr input = NULL; xmlErrorPtr to = &xmlLastError; - xmlChar *base = NULL; + xmlNodePtr baseptr = NULL; if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING)) return; if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || - (domain == XML_FROM_IO)) { + (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { ctxt = (xmlParserCtxtPtr) ctx; if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC)) @@ -509,14 +509,14 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel, int i; if ((node->doc != NULL) && (node->doc->URL != NULL)) - base = xmlStrdup(node->doc->URL); + baseptr = node; for (i = 0; ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE)); i++) node = node->parent; - if ((base == NULL) && (node != NULL) && + if ((baseptr == NULL) && (node != NULL) && (node->doc != NULL) && (node->doc->URL != NULL)) - base = xmlStrdup(node->doc->URL); + baseptr = node; if ((node != NULL) && (node->type == XML_ELEMENT_NODE)) line = node->line; @@ -532,9 +532,33 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel, to->level = level; if (file != NULL) to->file = (char *) xmlStrdup((const xmlChar *) file); - else if (base != NULL) { - to->file = (char *) base; - file = (char *) base; + else if (baseptr != NULL) { +#ifdef LIBXML_XINCLUDE_ENABLED + /* + * We check if the error is within an XInclude section and, + * if so, attempt to print out the href of the XInclude instead + * of the usual "base" (doc->URL) for the node (bug 152623). + */ + xmlNodePtr prev = baseptr; + int inclcount = 0; + while (prev != NULL) { + if (prev->prev == NULL) + prev = prev->parent; + else { + prev = prev->prev; + if (prev->type == XML_XINCLUDE_START) { + if (--inclcount < 0) + break; + } else if (prev->type == XML_XINCLUDE_END) + inclcount++; + } + } + if (prev != NULL) { + to->file = (char *) xmlGetProp(prev, BAD_CAST "href"); + } else +#endif + to->file = (char *) xmlStrdup(baseptr->doc->URL); + file = to->file; } to->line = line; if (str1 != NULL) |