fixed bug #310033, the URI extraction code given a node is a bit twisted

* error.c: fixed bug #310033, the URI extraction code given a
  node is a bit twisted and broke in the last months.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 6ffd0b0..ae64504 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 25 22:13:37 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+	* error.c: fixed bug #310033, the URI extraction code given a
+	  node is a bit twisted and broke in the last months.
+
 Thu Aug 25 16:18:15 CEST 2005 Daniel Veillard <daniel@veillard.com>
 
 	* debugXML.c result/XPath/xptr/strrange2: uninitialized field and
diff --git a/error.c b/error.c
index 4c2046a..ce63071 100644
--- a/error.c
+++ b/error.c
@@ -517,7 +517,7 @@
 
 	if ((node->doc != NULL) && (node->doc->URL != NULL)) {
 	    baseptr = node;
-	    file = (const char *) node->doc->URL;
+/*	    file = (const char *) node->doc->URL; */
 	}
 	for (i = 0;
 	     ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE));
@@ -563,10 +563,19 @@
 	    }
 	}
 	if (prev != NULL) {
-	    to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
+	    if (prev->type == XML_XINCLUDE_START) {
+		prev->type = XML_ELEMENT_NODE;
+		to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
+		prev->type = XML_XINCLUDE_START;
+	    } else {
+		to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
+	    }
 	} else
 #endif
 	    to->file = (char *) xmlStrdup(baseptr->doc->URL);
+	if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
+	    to->file = (char *) xmlStrdup(node->doc->URL);
+	}
 	file = to->file;
     }
     to->line = line;