Răsfoiți Sursa

2002-07-06 Ajay kumar Dwivedi <[email protected]>

	* XmlTextWriter: In WriteStartElement, if namespace is null and
		prefix is null|empty do not write out xmlns=""

	* XmlWriter: WriteStartElement calls the virtual method with null
		argument instead of empty string.

svn path=/trunk/mcs/; revision=5617
Ajay kumar Dwivedi 23 ani în urmă
părinte
comite
df14556dc1

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

@@ -1,3 +1,11 @@
+2002-07-06  Ajay kumar Dwivedi <[email protected]>
+
+	* XmlTextWriter: In WriteStartElement, if namespace is null and 
+		prefix is null|empty do not write out xmlns=""
+	
+	* XmlWriter: WriteStartElement calls the virtual method with null
+		argument instead of empty string.
+
 2002-07-05  Gonzalo Paniagua Javier <[email protected]>
 
 	* XmlTextReader.cs: implemented .ctor (Stream).

+ 21 - 20
mcs/class/System.XML/System.Xml/XmlTextWriter.cs

@@ -518,9 +518,6 @@ namespace System.Xml
 			if (prefix == null)
 				prefix = String.Empty;
 
-			if (ns == null)
-				ns = String.Empty;
-
 			if ((prefix != String.Empty) && ((ns == null) || (ns == String.Empty)))
 				throw new ArgumentException ("Cannot use a prefix with an empty namespace.");
 
@@ -530,26 +527,28 @@ namespace System.Xml
 			string formatXmlns = "";
 			string formatPrefix = "";
 
-			if (ns != String.Empty) 
+			if(ns != null)
 			{
-				string existingPrefix = namespaceManager.LookupPrefix (ns);
+				if (ns != String.Empty) 
+				{
+					string existingPrefix = namespaceManager.LookupPrefix (ns);
 
-				if (prefix == String.Empty)
-					prefix = existingPrefix;
+					if (prefix == String.Empty)
+						prefix = existingPrefix;
 
-				if (prefix != existingPrefix)
-					formatXmlns = String.Format (" xmlns:{0}={1}{2}{1}", prefix, quoteChar, ns);
-				else if (existingPrefix == String.Empty)
-					formatXmlns = String.Format (" xmlns={0}{1}{0}", quoteChar, ns);
-			}
-			else if ((prefix == String.Empty) && (namespaceManager.LookupNamespace(prefix) != String.Empty)) {
-				formatXmlns = String.Format (" xmlns={0}{0}", quoteChar);
-			}
+					if (prefix != existingPrefix)
+						formatXmlns = String.Format (" xmlns:{0}={1}{2}{1}", prefix, quoteChar, ns);
+					else if (existingPrefix == String.Empty)
+						formatXmlns = String.Format (" xmlns={0}{1}{0}", quoteChar, ns);
+				}
+				else if ((prefix == String.Empty) && (namespaceManager.LookupNamespace(prefix) != String.Empty)) {
+					formatXmlns = String.Format (" xmlns={0}{0}", quoteChar);
+				}
 
-			if (prefix != String.Empty) {
-				formatPrefix = prefix + ":";
+				if (prefix != String.Empty) {
+					formatPrefix = prefix + ":";
+				}
 			}
-
 			w.Write ("{0}<{1}{2}{3}", indentFormatting, formatPrefix, localName, formatXmlns);
 
 			openElements.Push (new XmlTextWriterOpenElement (formatPrefix + localName));
@@ -557,8 +556,10 @@ namespace System.Xml
 			openStartElement = true;
 
 			namespaceManager.PushScope ();
-			namespaceManager.AddNamespace (prefix, ns);
-
+			if(ns != null)
+			{
+				namespaceManager.AddNamespace (prefix, ns);
+			}
 			indentLevel++;
 		}
 

+ 2 - 2
mcs/class/System.XML/System.Xml/XmlWriter.cs

@@ -147,12 +147,12 @@ namespace System.Xml
 
 		public void WriteStartElement (string localName)
 		{
-			WriteStartElementInternal ("", localName, "");
+			WriteStartElementInternal (null, localName, null);
 		}
 
 		public void WriteStartElement (string localName, string ns)
 		{
-			WriteStartElement ("", localName, ns);
+			WriteStartElement (null, localName, ns);
 		}
 
 		public abstract void WriteStartElement (string prefix, string localName, string ns);