Browse Source

attributes() should return namespace declarations.

Tom Byrne 12 years ago
parent
commit
3580c0f921
1 changed files with 19 additions and 13 deletions
  1. 19 13
      std/flash/_std/Xml.hx

+ 19 - 13
std/flash/_std/Xml.hx

@@ -264,19 +264,25 @@ extern enum XmlType {
 	}
 	}
 
 
 	public function attributes() : Iterator<String> {
 	public function attributes() : Iterator<String> {
-		if( nodeType != Xml.Element )
-			throw "bad nodeType";
-		var attributes :XMLList = _node.attributes();
-		var names = Reflect.fields(attributes);
-		var cur = 0;
-		return {
-			hasNext : function(){
-				return cur < names.length;
-			},
-			next : function(){
-				return attributes[Std.parseInt(names[cur++])].name();
-			}
-		}
+	    if( nodeType != Xml.Element )
+	        throw "bad nodeType";
+	    var attributes :XMLList = _node.attributes();
+	    var names = Reflect.fields(attributes);
+	    var cur = 0;
+	    var nss = _node.namespaceDeclarations();
+	    return {
+	        hasNext : function(){
+	            return cur < names.length + nss.length;
+	        },
+	        next : function() {
+	            if(cur<names.length){
+	                return attributes[Std.parseInt(names[cur++])].name();
+	            }else {
+	                var ns:Namespace = nss[cur++ - names.length];
+	                return "xmlns:"+ns.prefix;
+	            }
+	        }
+	    }
 	}
 	}
 
 
 	public function iterator() : Iterator<Xml> {
 	public function iterator() : Iterator<Xml> {