added xmlDictExists() to the dictionnary interface. applying

* dict.c include/libxml/dict.h: added xmlDictExists() to the
  dictionnary interface.
* xmlreader.c: applying xmlTextReaderHasAttributes fix for namespaces
  from Rob Richards
Daniel
diff --git a/ChangeLog b/ChangeLog
index fb74dfd..c04b8d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Nov 24 13:41:52 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+	* dict.c include/libxml/dict.h: added xmlDictExists() to the 
+	  dictionnary interface.
+	* xmlreader.c: applying xmlTextReaderHasAttributes fix for namespaces
+	  from Rob Richards
+
 Wed Nov 17 13:54:37 CET 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
 
 	* xmlschemas.c: tiny enhancement for content model error reports (#157190, #143948).
diff --git a/dict.c b/dict.c
index 56c5dfb..2e0948c 100644
--- a/dict.c
+++ b/dict.c
@@ -486,7 +486,7 @@
  * @name: the name of the userdata
  * @len: the length of the name, if -1 it is recomputed
  *
- * Add the @name to the hash @dict if not present.
+ * Add the @name to the dictionnary @dict if not present.
  *
  * Returns the internal copy of the name or NULL in case of internal error
  */
@@ -600,6 +600,100 @@
 }
 
 /**
+ * xmlDictExists:
+ * @dict: the dictionnary
+ * @name: the name of the userdata
+ * @len: the length of the name, if -1 it is recomputed
+ *
+ * Check if the @name exists in the dictionnary @dict.
+ *
+ * Returns the internal copy of the name or NULL if not found.
+ */
+const xmlChar *
+xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
+    unsigned long key, okey, nbi = 0;
+    xmlDictEntryPtr entry;
+    xmlDictEntryPtr insert;
+    const xmlChar *ret;
+
+    if ((dict == NULL) || (name == NULL))
+	return(NULL);
+
+    if (len < 0)
+        len = xmlStrlen(name);
+
+    /*
+     * Check for duplicate and insertion location.
+     */
+    okey = xmlDictComputeKey(name, len);
+    key = okey % dict->size;
+    if (dict->dict[key].valid == 0) {
+	insert = NULL;
+    } else {
+	for (insert = &(dict->dict[key]); insert->next != NULL;
+	     insert = insert->next) {
+#ifdef __GNUC__
+	    if (insert->len == len) {
+		if (!memcmp(insert->name, name, len))
+		    return(insert->name);
+	    }
+#else
+	    if ((insert->len == len) &&
+	        (!xmlStrncmp(insert->name, name, len)))
+		return(insert->name);
+#endif
+	    nbi++;
+	}
+#ifdef __GNUC__
+	if (insert->len == len) {
+	    if (!memcmp(insert->name, name, len))
+		return(insert->name);
+	}
+#else
+	if ((insert->len == len) &&
+	    (!xmlStrncmp(insert->name, name, len)))
+	    return(insert->name);
+#endif
+    }
+
+    if (dict->subdict) {
+	key = okey % dict->subdict->size;
+	if (dict->subdict->dict[key].valid != 0) {
+	    xmlDictEntryPtr tmp;
+
+	    for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
+		 tmp = tmp->next) {
+#ifdef __GNUC__
+		if (tmp->len == len) {
+		    if (!memcmp(tmp->name, name, len))
+			return(tmp->name);
+		}
+#else
+		if ((tmp->len == len) &&
+		    (!xmlStrncmp(tmp->name, name, len)))
+		    return(tmp->name);
+#endif
+		nbi++;
+	    }
+#ifdef __GNUC__
+	    if (tmp->len == len) {
+		if (!memcmp(tmp->name, name, len))
+		    return(tmp->name);
+	    }
+#else
+	    if ((tmp->len == len) &&
+		(!xmlStrncmp(tmp->name, name, len)))
+		return(tmp->name);
+#endif
+	}
+	key = okey % dict->size;
+    }
+
+    /* not found */
+    return(NULL);
+}
+
+/**
  * xmlDictQLookup:
  * @dict: the dictionnary
  * @prefix: the prefix 
diff --git a/include/libxml/dict.h b/include/libxml/dict.h
index 874ba3d..6bf25fb 100644
--- a/include/libxml/dict.h
+++ b/include/libxml/dict.h
@@ -44,6 +44,10 @@
 		                         const xmlChar *name,
 		                         int len);
 XMLPUBFUN const xmlChar * XMLCALL		
+			xmlDictExists	(xmlDictPtr dict,
+		                         const xmlChar *name,
+		                         int len);
+XMLPUBFUN const xmlChar * XMLCALL		
 			xmlDictQLookup	(xmlDictPtr dict,
 		                         const xmlChar *prefix,
 		                         const xmlChar *name);
diff --git a/xmlreader.c b/xmlreader.c
index a5aba32..20aee7e 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -3215,7 +3215,7 @@
 	node = reader->node;
 
     if ((node->type == XML_ELEMENT_NODE) &&
-	(node->properties != NULL))
+	((node->properties != NULL) || (node->nsDef != NULL)))
 	return(1);
     /* TODO: handle the xmlDecl */
     return(0);