فهرست منبع

2009-02-06 Atsushi Enomoto <[email protected]>

	* XmlTextWriter2.cs : in WriteStartAttribute(), fill namespace in
	  case it is null and the prefix has matching ns. Fixed bug #472634.

	* XmlTextWriterTests.cs : added test for bug #472634.


svn path=/trunk/mcs/; revision=126047
Atsushi Eno 17 سال پیش
والد
کامیت
fbda9fbe5d

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

@@ -1,3 +1,8 @@
+2009-02-06  Atsushi Enomoto  <[email protected]>
+
+	* XmlTextWriter2.cs : in WriteStartAttribute(), fill namespace in
+	  case it is null and the prefix has matching ns. Fixed bug #472634.
+
 2009-01-30  Atsushi Enomoto  <[email protected]>
 
 	* DTDValidatingReader2.cs, EntityResolvingXmlReader.cs : simplify

+ 5 - 2
mcs/class/System.XML/System.Xml/XmlTextWriter2.cs

@@ -843,8 +843,11 @@ namespace Mono.Xml
 
 				// If namespace URI is empty, then prefix
 				// must be empty as well.
-				if (prefix.Length > 0 && namespaceUri.Length == 0)
-					throw ArgumentError ("Namespace URI must not be null when prefix is not an empty string.");
+				if (prefix.Length > 0 && namespaceUri.Length == 0) {
+					namespaceUri = nsmanager.LookupNamespace (prefix, false);
+					if (namespaceUri == null || namespaceUri.Length == 0)
+						throw ArgumentError ("Namespace URI must not be null when prefix is not an empty string.");
+				}
 
 				// Dive into extremely complex procedure.
 				if (!isNSDecl && namespaceUri.Length > 0)

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

@@ -1,3 +1,7 @@
+2009-02-06  Atsushi Enomoto  <[email protected]>
+
+	* XmlTextWriterTests.cs : added test for bug #472634.
+
 2009-01-20  Atsushi Enomoto  <[email protected]>
 
 	* XmlReaderCommonTests.cs : added test for bug #464229.

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

@@ -2320,6 +2320,18 @@ namespace MonoTests.System.Xml
 			Assert.IsTrue (xml.IndexOf ("xmlns", first + 5) > 0);
 		}
 
+		[Test]
+		public void WriteAttributePrefixedNullNamespace ()
+		{
+			StringWriter sw = new StringWriter ();
+			XmlWriter xw = new XmlTextWriter (sw);
+			xw.WriteStartElement ("root");
+			xw.WriteAttributeString ("xmlns", "abc", null, "uri:abcnamespace");
+			xw.WriteAttributeString ("abc", "def", null, "value");
+			xw.WriteEndElement ();
+			Assert.AreEqual ("<root xmlns:abc=\"uri:abcnamespace\" abc:def=\"value\" />", sw.ToString ());
+		}
+
 #if NET_2_0
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]