fixing a comment fixing some troubles with validity check on namespaces

* include/libxml/entities.h: fixing a comment
* valid.c: fixing some troubles with validity check on namespaces
* result/VC/NS3 test/VC/NS3: added a specific regression test
Daniel
diff --git a/valid.c b/valid.c
index 9df5710..55b8212 100644
--- a/valid.c
+++ b/valid.c
@@ -4369,42 +4369,64 @@
     attr = elemDecl->attributes;
     while (attr != NULL) {
 	if (attr->def == XML_ATTRIBUTE_REQUIRED) {
-	    xmlAttrPtr attrib;
 	    int qualified = -1;
-	    
-	    attrib = elem->properties;
-	    while (attrib != NULL) {
-		if (xmlStrEqual(attrib->name, attr->name)) {
-		    if (attr->prefix != NULL) {
-		        xmlNsPtr nameSpace = attrib->ns;
 
-			if (nameSpace == NULL)
-			    nameSpace = elem->ns;
-			/*
-			 * qualified names handling is problematic, having a
-			 * different prefix should be possible but DTDs don't
-			 * allow to define the URI instead of the prefix :-(
-			 */
-			if (nameSpace == NULL) {
-			    if (qualified < 0) 
-				qualified = 0;
-	    		} else if (!xmlStrEqual(nameSpace->prefix,
-				                attr->prefix)) {
-			    if (qualified < 1) 
-				qualified = 1;
-			} else
-			    goto found;
-		    } else {
-		        /*
-			 * We should allow applications to define namespaces
-			 * for their application even if the DTD doesn't 
-			 * carry one, otherwise, basically we would always
-			 * break.
-			 */
+	    if ((attr->prefix == NULL) &&
+		(xmlStrEqual(attr->name, BAD_CAST "xmlns"))) {
+		xmlNsPtr ns;
+
+		ns = elem->nsDef;
+		while (ns != NULL) {
+		    if (ns->prefix == NULL)
 			goto found;
-		    }
+		    ns = ns->next;
 		}
-		attrib = attrib->next;
+	    } else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) {
+		xmlNsPtr ns;
+
+		ns = elem->nsDef;
+		while (ns != NULL) {
+		    if (xmlStrEqual(attr->name, ns->prefix))
+			goto found;
+		    ns = ns->next;
+		}
+	    } else {
+		xmlAttrPtr attrib;
+		
+		attrib = elem->properties;
+		while (attrib != NULL) {
+		    if (xmlStrEqual(attrib->name, attr->name)) {
+			if (attr->prefix != NULL) {
+			    xmlNsPtr nameSpace = attrib->ns;
+
+			    if (nameSpace == NULL)
+				nameSpace = elem->ns;
+			    /*
+			     * qualified names handling is problematic, having a
+			     * different prefix should be possible but DTDs don't
+			     * allow to define the URI instead of the prefix :-(
+			     */
+			    if (nameSpace == NULL) {
+				if (qualified < 0) 
+				    qualified = 0;
+			    } else if (!xmlStrEqual(nameSpace->prefix,
+						    attr->prefix)) {
+				if (qualified < 1) 
+				    qualified = 1;
+			    } else
+				goto found;
+			} else {
+			    /*
+			     * We should allow applications to define namespaces
+			     * for their application even if the DTD doesn't 
+			     * carry one, otherwise, basically we would always
+			     * break.
+			     */
+			    goto found;
+			}
+		    }
+		    attrib = attrib->next;
+		}
 	    }
 	    if (qualified == -1) {
 		if (attr->prefix == NULL) {
@@ -4427,6 +4449,44 @@
 		   "Element %s required attribute %s:%s has different prefix\n",
 		       elem->name, attr->prefix,attr->name);
 	    }
+	} else if (attr->def == XML_ATTRIBUTE_FIXED) {
+	    /*
+	     * Special tests checking #FIXED namespace declarations
+	     * have the right value since this is not done as an
+	     * attribute checking
+	     */
+	    if ((attr->prefix == NULL) &&
+		(xmlStrEqual(attr->name, BAD_CAST "xmlns"))) {
+		xmlNsPtr ns;
+
+		ns = elem->nsDef;
+		while (ns != NULL) {
+		    if (ns->prefix == NULL) {
+			if (!xmlStrEqual(attr->defaultValue, ns->href)) {
+			    VERROR(ctxt->userData,
+   "Element %s namespace name for default namespace does not match the DTD\n",
+				   elem->name);
+			}
+			goto found;
+		    }
+		    ns = ns->next;
+		}
+	    } else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) {
+		xmlNsPtr ns;
+
+		ns = elem->nsDef;
+		while (ns != NULL) {
+		    if (xmlStrEqual(attr->name, ns->prefix)) {
+			if (!xmlStrEqual(attr->defaultValue, ns->href)) {
+			    VERROR(ctxt->userData,
+		   "Element %s namespace name for %s doesn't match the DTD\n",
+				   elem->name, ns->prefix);
+			}
+			goto found;
+		    }
+		    ns = ns->next;
+		}
+	    }
 	}
 found:	    
         attr = attr->nexth;