- tree.[ch] parser.c xpath.c: fixed the problem of addressing
  attributes within the XML-1.0 namespace
Daniel
diff --git a/ChangeLog b/ChangeLog
index 6d02d4b..d421eb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Feb 16 01:10:06 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+	* tree.[ch] parser.c xpath.c: fixed the problem of addressing
+	  attributes within the XML-1.0 namespace
+
 Thu Feb 15 16:53:20 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* xpathInternals.h: exported a few axis functions
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
index de7cf79..648817d 100644
--- a/include/libxml/tree.h
+++ b/include/libxml/tree.h
@@ -20,6 +20,9 @@
 extern "C" {
 #endif
 
+#define XML_XML_NAMESPACE \
+    (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
+
 /*
  * The different element types carried by an XML tree
  *
diff --git a/parser.c b/parser.c
index d46a9b1..7afee9f 100644
--- a/parser.c
+++ b/parser.c
@@ -1473,10 +1473,12 @@
 
     *prefix = NULL;
 
+#ifndef XML_XML_NAMESPACE
     /* xml: prefix is not really a namespace */
     if ((cur[0] == 'x') && (cur[1] == 'm') &&
         (cur[2] == 'l') && (cur[3] == ':'))
 	return(xmlStrdup(name));
+#endif
 
     /* nasty but valid */
     if (cur[0] == ':')
diff --git a/tree.c b/tree.c
index 45a10af..5339e9f 100644
--- a/tree.c
+++ b/tree.c
@@ -3615,6 +3615,26 @@
     xmlNsPtr cur;
 
     if (node == NULL) return(NULL);
+    if ((nameSpace != NULL) &&
+	(xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) {
+	if (doc->oldNs == NULL) {
+	    /*
+	     * Allocate a new Namespace and fill the fields.
+	     */
+	    doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
+	    if (doc->oldNs == NULL) {
+		xmlGenericError(xmlGenericErrorContext,
+			"xmlSearchNsByHref : malloc failed\n");
+		return(NULL);
+	    }
+	    memset(doc->oldNs, 0, sizeof(xmlNs));
+	    doc->oldNs->type = XML_LOCAL_NAMESPACE;
+
+	    doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE); 
+	    doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml"); 
+	}
+	return(doc->oldNs);
+    }
     while (node != NULL) {
 	if ((node->type == XML_ENTITY_REF_NODE) ||
 	    (node->type == XML_ENTITY_NODE) ||
@@ -3654,6 +3674,25 @@
     xmlNodePtr orig = node;
 
     if ((node == NULL) || (href == NULL)) return(NULL);
+    if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
+	if (doc->oldNs == NULL) {
+	    /*
+	     * Allocate a new Namespace and fill the fields.
+	     */
+	    doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
+	    if (doc->oldNs == NULL) {
+		xmlGenericError(xmlGenericErrorContext,
+			"xmlSearchNsByHref : malloc failed\n");
+		return(NULL);
+	    }
+	    memset(doc->oldNs, 0, sizeof(xmlNs));
+	    doc->oldNs->type = XML_LOCAL_NAMESPACE;
+
+	    doc->oldNs->href = xmlStrdup(XML_XML_NAMESPACE); 
+	    doc->oldNs->prefix = xmlStrdup((const xmlChar *)"xml"); 
+	}
+	return(doc->oldNs);
+    }
     while (node != NULL) {
 	cur = node->nsDef;
 	while (cur != NULL) {
diff --git a/tree.h b/tree.h
index de7cf79..648817d 100644
--- a/tree.h
+++ b/tree.h
@@ -20,6 +20,9 @@
 extern "C" {
 #endif
 
+#define XML_XML_NAMESPACE \
+    (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
+
 /*
  * The different element types carried by an XML tree
  *
diff --git a/xpath.c b/xpath.c
index b8e9460..87e9c2c 100644
--- a/xpath.c
+++ b/xpath.c
@@ -1344,6 +1344,12 @@
 	return(NULL);
     if (prefix == NULL)
 	return(NULL);
+
+#ifdef XML_XML_NAMESPACE
+    if (xmlStrEqual(prefix, (const xmlChar *) "xml"))
+	return(XML_XML_NAMESPACE);
+#endif
+
     if (ctxt->nsHash == NULL)
 	return(NULL);
 
@@ -3289,10 +3295,24 @@
 		        case XML_ATTRIBUTE_NODE: {
 			    xmlAttrPtr attr = (xmlAttrPtr) cur;
 			    if (xmlStrEqual(name, attr->name)) {
+				if (prefix == NULL) {
+				    if ((attr->ns == NULL) ||
+					(attr->ns->prefix == NULL)) {
 #ifdef DEBUG_STEP
-				n++;
+					n++;
 #endif
-				addNode(ret, cur);
+					addNode(ret, attr);
+				    }
+				} else {
+				    if ((attr->ns != NULL) && 
+				        (xmlStrEqual(prefix,
+						     attr->ns->href))) {
+#ifdef DEBUG_STEP
+					n++;
+#endif
+					addNode(ret, attr);
+				    }
+				}
 			    }
 			    break;
 			}