2003/11/22 07:48:52
[org.ibex.core.git] / src / org / xwt / util / XML.java
index 099acce..e652f38 100644 (file)
@@ -452,21 +452,19 @@ public abstract class XML
                 current.defaultUri = v;
             }
         } else {
-            // check to see if attribute is a repeat
-            for (int i=0; current.len > i; i++) if (n.equals(current.keys[i])) throw new WFCException(
-                "attribute name '"+n+"' may not appear more than once in the same element tag", getLine(), getCol()
-            );
-
             // find attribute uri
             if (p == null) {
-                u = current.uri;
+                for (Element e = current; e != null && u == null; e = e.prev) { u = e.uri; }
             } else {
-                for (Element e = current; e != null && u == null; e = e.prev) {
-                    u = (String)e.urimap.get(p);
-                }
+                for (Element e = current; e != null && u == null; e = e.prev) { u = (String)e.urimap.get(p); }
                 if (u == null) current.addError(new NCException("undefined attribute prefix '"+current.prefix+"'", getLine(), getCol()));
             }
 
+            // check to see if attribute is a repeat
+            for (int i=0; current.len > i; i++) if (n.equals(current.keys[i]) && u.equals(current.uris[i])) throw new WFCException(
+                "attribute name '"+n+"' may not appear more than once in the same element tag", getLine(), getCol()
+            );
+
             // add attribute to the attribute arrays
             if (current.len == current.keys.length) current.morekeys();
             current.keys[current.len] = n;
@@ -851,7 +849,11 @@ public abstract class XML
 
         /** empty out the arrays */
         void clear() {
-            for (int i=0; len > i; i++) { keys[i] = null; vals[i] = null; uris[i] = null; }; len = 0;
+            if (keys.length != vals.length || vals.length != uris.length) {
+                keys = new String[10]; vals = new String[10]; uris = new String[10];
+            } else {
+                for (int i=0; keys.length > i; i++) { keys[i] = null; vals[i] = null; uris[i] = null; }; len = 0;
+            }
             errors = new XMLException[] {};
         }