Browse Source

XmlTextWriter.cs (WriteStartAttribute) : Check if the ket already exists in the newAttributeNamespaces table
before trying to add it to the table.

svn path=/trunk/mcs/; revision=20259

Eran Domb 22 years ago
parent
commit
f6d1555aa1

+ 5 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2003-11-20 Eran Domb <[email protected]>
+
+	* XmlTextWriter.cs (WriteStartAttribute) : Check if the ket already exists in the newAttributeNamespaces table 
+	  before trying to add it to the table.
+
 2003-11-19  Atsushi Enomoto  <[email protected]>
 
 	* DTDValidatingReader.cs : Replaced entity should not treat whitespaces

+ 6 - 1
mcs/class/System.XML/System.Xml/XmlTextWriter.cs

@@ -663,7 +663,12 @@ namespace System.Xml
 					}
 					if (createPrefix)
 						prefix = "d" + indentLevel + "p" + (newAttributeNamespaces.Count + 1);
-					newAttributeNamespaces.Add (prefix, ns);
+					
+					// check if prefix exists. If yes - check if namespace is the same.
+					if (newAttributeNamespaces [prefix] == null)
+						newAttributeNamespaces.Add (prefix, ns);
+					else if (!newAttributeNamespaces [prefix].Equals (ns))
+						throw new ArgumentException ("Duplicate prefix with different namespace");
 				}
 
 				if (prefix == String.Empty && ns != XmlnsNamespace)