Переглянути джерело

2002-12-21 Atsushi Enomoto <[email protected]>

	* XmlElement.cs, XmlTextWriter.cs, XmlWriter.cs:
		patch by JD Conley <[email protected]>.
		(Fix for xmlns attribute output.)

svn path=/trunk/mcs/; revision=9798
Atsushi Eno 23 роки тому
батько
коміт
f00c428bbe

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

@@ -1,3 +1,9 @@
+2002-12-21  Atsushi Enomoto <[email protected]>
+
+	* XmlElement.cs, XmlTextWriter.cs, XmlWriter.cs:
+		patch by JD Conley <[email protected]>.
+		(Fix for xmlns attribute output.)
+
 2002-12-05  Ville Palo <[email protected]>
 
 	* XmlQualifiedName.cs: Little fix to ToString () -method

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

@@ -358,14 +358,14 @@ namespace System.Xml
 			w.WriteStartElement(Prefix, LocalName, NamespaceURI);
 
 			// write namespace declarations(if not exist)
-			if(Prefix != null && w.LookupPrefix(Prefix) != NamespaceURI)
+			if(Prefix != null && Prefix != String.Empty && w.LookupPrefix(Prefix) != NamespaceURI)
 				w.WriteAttributeString("xmlns", Prefix, "http://www.w3.org/2000/xmlns/", NamespaceURI);
 
 			foreach(XmlNode attributeNode in Attributes)
 			{
 				attributeNode.WriteTo(w);
 				// write namespace declarations(if not exist)
-				if(attributeNode.Prefix != null && attributeNode.Prefix != "" &&
+				if(attributeNode.Prefix != null && attributeNode.Prefix != String.Empty &&
 				   w.LookupPrefix(attributeNode.Prefix) != attributeNode.NamespaceURI &&
 				   attributeNode.Prefix != "xmlns")
 					w.WriteAttributeString("xmlns", attributeNode.Prefix, "http://www.w3.org/2000/xmlns/", attributeNode.NamespaceURI);

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

@@ -561,6 +561,7 @@ namespace System.Xml
 						namespaceManager.AddNamespace (prefix, ns);
 						addDefaultNamespace = true;
 					}
+
 					if (prefix == String.Empty)
 						prefix = existingPrefix;
 

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

@@ -61,7 +61,7 @@ namespace System.Xml
 					if(decl.Standalone != null && decl.Standalone != String.Empty) WriteAttributeString("standalone", decl.Standalone);
 					break;
 				case XmlNodeType.Element:
-					while (reader.MoveToNextAttribute ()) 
+					while (reader.MoveToNextAttribute ()) 
 					{
 						WriteAttributeString(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value);
 					}
@@ -71,7 +71,7 @@ namespace System.Xml
 					{
 						WriteAttributeString(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.Value);
 					}
-					while (reader.MoveToNextAttribute ()) ;
+					while (reader.MoveToNextAttribute ()) ;
 					break;
 				default:
 					throw new XmlException("NodeType is not one of Element, Attribute, nor XmlDeclaration.");
@@ -93,10 +93,14 @@ namespace System.Xml
 			if ((prefix == "xmlns") || (localName == "xmlns"))
 			  {
 				ns = value;
+				
 				if (prefix == "xmlns" && namespaceManager.HasNamespace (localName))
 				  	return;
+				
+				/* Users need to be able to re-declare the default namespace for subnodes
 				else if (localName == "xmlns" && namespaceManager.HasNamespace (String.Empty))
 				  	return;
+				*/
 			  }
 			
 			WriteStartAttribute (prefix, localName, ns);
@@ -110,6 +114,7 @@ namespace System.Xml
 				else
 					namespaceManager.AddNamespace ("", ns);
 			}
+			
 		}
 
 		public abstract void WriteBase64 (byte[] buffer, int index, int count);