Procházet zdrojové kódy

2005-03-02 Atsushi Enomoto <[email protected]>

	* XmlTextWriter.cs : LookupPrefix() should not return those prefix
	  that is overriden by another xmlns declaration.

	* XmlTextWriterTests.cs : Added test for LookupPrefix() for
	  overriden prefix.


svn path=/trunk/mcs/; revision=41372
Atsushi Eno před 21 roky
rodič
revize
5527fe3ce9

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

@@ -1,3 +1,8 @@
+2005-03-02  Atsushi Enomoto <[email protected]>
+
+	* XmlTextWriter.cs : LookupPrefix() should not return those prefix
+	  that is overriden by another xmlns declaration.
+
 2005-02-26  Atsushi Enomoto <[email protected]>
 
 	* XmlEntity.cs : it was not returning SYSTEM ID when there is no

+ 4 - 0
mcs/class/System.XML/System.Xml/XmlTextWriter.cs

@@ -410,6 +410,10 @@ openElements [openElementCount - 1]).IndentingOverriden;
 				throw new ArgumentException ("The Namespace cannot be empty.");
 
 			string prefix = namespaceManager.LookupPrefix (ns, false);
+			// XmlNamespaceManager might return such prefix that
+			// is *previously* mapped to ns passed above.
+			if (prefix == null || namespaceManager.LookupNamespace (prefix) != ns)
+				return null;
 
 			// XmlNamespaceManager has changed to return null when NSURI not found.
 			// (Contradiction to the ECMA documentation.)

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

@@ -1,3 +1,8 @@
+2005-03-02  Atsushi Enomoto <[email protected]>
+
+	* XmlTextWriterTests.cs : Added test for LookupPrefix() for
+	  overriden prefix.
+
 2005-02-25  Atsushi Enomoto <[email protected]>
 
 	* XmlNodeTests.cs : added Clone() of readonly node returns a node

+ 9 - 0
mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests.cs

@@ -1308,5 +1308,14 @@ namespace MonoTests.System.Xml
 			xtw.WriteString ("foo");
 			AssertEquals (WriteState.Content, xtw.WriteState);
 		}
+
+		[Test]
+		public void LookupOverridenPrefix ()
+		{
+			xtw.WriteStartElement ("out");
+			xtw.WriteAttributeString ("xmlns", "baz", "http://www.w3.org/2000/xmlns/", "xyz");
+			xtw.WriteStartElement ("baz", "foo", "abc");
+			AssertNull (xtw.LookupPrefix ("xyz"));
+		}
 	}
 }