swapped the attribute defaulting and attribute checking parts of parsing a

* parser.c: swapped the attribute defaulting and attribute checking
  parts of parsing a new element start, fixes bug #127772
* result/valid/127772.* test/valid/127772.xml
  test/valid/dtds/127772.dtd: added the example in the regression tests
Daniel
diff --git a/ChangeLog b/ChangeLog
index d2f1604..e6ebe4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Nov 25 08:18:12 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+	* parser.c: swapped the attribute defaulting and attribute checking
+	  parts of parsing a new element start, fixes bug #127772
+	* result/valid/127772.* test/valid/127772.xml
+	  test/valid/dtds/127772.dtd: added the example in the regression tests
+
 Tue Nov 25 08:00:15 CET 2003 Daniel Veillard <daniel@veillard.com>
 
 	* parser.c: moved xmlCleanupThreads() to the end of xmlCleanupParser()
diff --git a/parser.c b/parser.c
index 49ef8eb..2a47b24 100644
--- a/parser.c
+++ b/parser.c
@@ -7842,39 +7842,6 @@
     }
 
     /*
-     * The attributes checkings
-     */
-    for (i = 0; i < nbatts;i += 5) {
-        nsname = xmlGetNamespace(ctxt, atts[i + 1]);
-	if ((atts[i + 1] != NULL) && (nsname == NULL)) {
-	    xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
-		 "Namespace prefix %s for %s on %s is not defined\n",
-		     atts[i + 1], atts[i], localname);
-	}
-	atts[i + 2] = nsname;
-	/*
-	 * [ WFC: Unique Att Spec ]
-	 * No attribute name may appear more than once in the same
-	 * start-tag or empty-element tag. 
-	 * As extended by the Namespace in XML REC.
-	 */
-        for (j = 0; j < i;j += 5) {
-	    if (atts[i] == atts[j]) {
-	        if (atts[i+1] == atts[j+1]) {
-		    xmlErrAttributeDup(ctxt, atts[i+1], atts[i]);
-		    break;
-		}
-		if ((nsname != NULL) && (atts[j + 2] == nsname)) {
-		    xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,
-			     "Namespaced Attribute %s in '%s' redefined\n",
-			     atts[i], nsname, NULL);
-		    break;
-		}
-	    }
-	}
-    }
-
-    /*
      * The attributes defaulting
      */
     if (ctxt->attsDefault != NULL) {
@@ -7950,6 +7917,39 @@
 	}
     }
 
+    /*
+     * The attributes checkings
+     */
+    for (i = 0; i < nbatts;i += 5) {
+        nsname = xmlGetNamespace(ctxt, atts[i + 1]);
+	if ((atts[i + 1] != NULL) && (nsname == NULL)) {
+	    xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
+		 "Namespace prefix %s for %s on %s is not defined\n",
+		     atts[i + 1], atts[i], localname);
+	}
+	atts[i + 2] = nsname;
+	/*
+	 * [ WFC: Unique Att Spec ]
+	 * No attribute name may appear more than once in the same
+	 * start-tag or empty-element tag. 
+	 * As extended by the Namespace in XML REC.
+	 */
+        for (j = 0; j < i;j += 5) {
+	    if (atts[i] == atts[j]) {
+	        if (atts[i+1] == atts[j+1]) {
+		    xmlErrAttributeDup(ctxt, atts[i+1], atts[i]);
+		    break;
+		}
+		if ((nsname != NULL) && (atts[j + 2] == nsname)) {
+		    xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,
+			     "Namespaced Attribute %s in '%s' redefined\n",
+			     atts[i], nsname, NULL);
+		    break;
+		}
+	    }
+	}
+    }
+
     nsname = xmlGetNamespace(ctxt, prefix);
     if ((prefix != NULL) && (nsname == NULL)) {
 	xmlNsErr(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
diff --git a/result/valid/127772.xml b/result/valid/127772.xml
new file mode 100644
index 0000000..c1e128f
--- /dev/null
+++ b/result/valid/127772.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<!DOCTYPE a SYSTEM "dtds/127772.dtd">
+<a>
+  <b xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://fakeurl.net">b text</b>
+</a>
diff --git a/result/valid/127772.xml.err b/result/valid/127772.xml.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/result/valid/127772.xml.err
diff --git a/test/valid/127772.xml b/test/valid/127772.xml
new file mode 100644
index 0000000..ba39194
--- /dev/null
+++ b/test/valid/127772.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE a SYSTEM "dtds/127772.dtd">
+
+<a>
+  <b xlink:href="http://fakeurl.net">b text</b>
+</a>
+
diff --git a/test/valid/dtds/127772.dtd b/test/valid/dtds/127772.dtd
new file mode 100644
index 0000000..873fb35
--- /dev/null
+++ b/test/valid/dtds/127772.dtd
@@ -0,0 +1,7 @@
+<!ELEMENT a (b*)>
+
+<!ELEMENT b (#PCDATA)>
+<!ATTLIST b xmlns:xlink  CDATA     #FIXED 'http://www.w3.org/1999/xlink'
+            xlink:type   (simple)  #FIXED 'simple'
+            xlink:href   CDATA     #IMPLIED>
+