fixing bug #79331 in one path the lookup for ID attributes on a namespaced

* valid.c: fixing bug #79331 in one path the lookup for
  ID attributes on a namespaced node wasn't handled correctly :-\
Daniel
diff --git a/ChangeLog b/ChangeLog
index bb09dd0..70c31f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jul  6 19:44:56 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+	* valid.c: fixing bug #79331 in one path the lookup for
+	  ID attributes on a namespaced node wasn't handled correctly :-\
+
 Fri Jul  5 20:07:43 CEST 2002 Daniel Veillard <daniel@veillard.com>
 
 	* HTMLparser.c: trying to fix 87235 about discarded white
diff --git a/valid.c b/valid.c
index 597a0ff..114ae5f 100644
--- a/valid.c
+++ b/valid.c
@@ -1928,10 +1928,31 @@
 	xmlAttributePtr attrDecl;
 
 	if (elem == NULL) return(0);
-	attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name);
-	if ((attrDecl == NULL) && (doc->extSubset != NULL))
-	    attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name,
-	                                 attr->name);
+	if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
+	    /*
+	     * TODO: this sucks ... recomputing this every time is stupid
+	     */
+	    int len = xmlStrlen(elem->name) + xmlStrlen(elem->ns->prefix) + 2;
+	    xmlChar *fullname;
+
+	    fullname = xmlMalloc(len);
+	    if (fullname == NULL)
+		return(0);
+	    snprintf((char *) fullname, len, "%s:%s", (char *) elem->ns->prefix,
+		     (char *) elem->name);
+	    attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname,
+		                         attr->name);
+	    if ((attrDecl == NULL) && (doc->extSubset != NULL))
+		attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname,
+					     attr->name);
+	    xmlFree(fullname);
+	} else {
+	    attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name,
+		                         attr->name);
+	    if ((attrDecl == NULL) && (doc->extSubset != NULL))
+		attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name,
+					     attr->name);
+	}
 
         if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID))
 	    return(1);