improved the behaviour a bit as well as the logs fixed a few more bugs

* check-xml-test-suite.py: improved the behaviour a bit as
  well as the logs
* parser.c valid.c SAX.c: fixed a few more bugs
  "Ran 1819 tests: 1778 suceeded, 41 failed, and 0 generated an error"
Daniel
diff --git a/SAX.c b/SAX.c
index da13370..022c0fb 100644
--- a/SAX.c
+++ b/SAX.c
@@ -479,6 +479,7 @@
             elem, fullname, type, def, defaultValue);
 #endif
     name = xmlSplitQName(ctxt, fullname, &prefix);
+    ctxt->vctxt.valid = 1;
     if (ctxt->inSubset == 1)
 	attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
 	       name, prefix, (xmlAttributeType) type,
@@ -493,7 +494,8 @@
 	     "SAX.attributeDecl(%s) called while not in subset\n", name);
 	return;
     }
-    /* if (attr == 0) ctxt->valid = 0; */
+    if (ctxt->vctxt.valid == 0)
+	ctxt->valid = 0;
     if (ctxt->validate && ctxt->wellFormed &&
         ctxt->myDoc && ctxt->myDoc->intSubset)
 	ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
@@ -892,10 +894,25 @@
 	    val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
 		                          0,0,0);
 	    ctxt->depth--;
+	    
 	    if (val == NULL)
 		ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
 				ctxt->myDoc, ctxt->node, ret, value);
 	    else {
+		xmlChar *nvalnorm;
+
+		/*
+		 * Do the last stage of the attribute normalization
+		 * It need to be done twice ... it's an extra burden related
+		 * to the ability to keep references in attributes
+		 */
+		nvalnorm = xmlValidNormalizeAttributeValue(ctxt->myDoc,
+					    ctxt->node, fullname, val);
+		if (nvalnorm != NULL) {
+		    xmlFree(val);
+		    val = nvalnorm;
+		}
+
 		ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
 			        ctxt->myDoc, ctxt->node, ret, val);
                 xmlFree(val);