瀏覽代碼

2006-01-27 Atsushi Enomoto <[email protected]>

	* XmlNode.cs,
	  XmlDocument.cs,
	  XmlAttribute.cs,
	  XmlElement.cs :
	  Added internal AppendChild() override that omites node type
	  checking, and used it in many places.


svn path=/trunk/mcs/; revision=56151
Atsushi Eno 20 年之前
父節點
當前提交
f98a6cf05b

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

@@ -1,3 +1,12 @@
+2006-01-27  Atsushi Enomoto <[email protected]>
+
+	* XmlNode.cs,
+	  XmlDocument.cs,
+	  XmlAttribute.cs,
+	  XmlElement.cs :
+	  Added internal AppendChild() override that omites node type
+	  checking, and used it in many places.
+
 2006-01-27  Atsushi Enomoto <[email protected]>
 
 	* XmlDocument.cs : optimized ReadAttributeNode() to not call

+ 3 - 3
mcs/class/System.XML/System.Xml/XmlAttribute.cs

@@ -234,11 +234,11 @@ namespace System.Xml
 				XmlNode textChild = FirstChild as XmlCharacterData;
 				if (textChild == null) {
 					this.RemoveAll ();
-					AppendChild (OwnerDocument.CreateTextNode (value));
+					AppendChild (OwnerDocument.CreateTextNode (value), false);
 				}
 				else if (FirstChild.NextSibling != null) {
 					this.RemoveAll ();
-					AppendChild (OwnerDocument.CreateTextNode (value));
+					AppendChild (OwnerDocument.CreateTextNode (value), false);
 				}
 				else
 					textChild.Value = value;
@@ -296,7 +296,7 @@ namespace System.Xml
 							 OwnerDocument, true, false);
 			if (deep) {
 				for (int i = 0; i < ChildNodes.Count; i++)
-					node.AppendChild (ChildNodes [i].CloneNode (deep));
+					node.AppendChild (ChildNodes [i].CloneNode (deep), false);
 			}
 
 			return node;

+ 5 - 5
mcs/class/System.XML/System.Xml/XmlDocument.cs

@@ -270,7 +270,7 @@ namespace System.Xml
 			if(deep)
 			{
 				for (XmlNode n = FirstChild; n != null; n = n.NextSibling)
-					doc.AppendChild (doc.ImportNode (n, deep));
+					doc.AppendChild (doc.ImportNode (n, deep), false);
 			}
 			return doc;
 		}
@@ -676,7 +676,7 @@ namespace System.Xml
 					if (n == null)
 						break;
 					if (preserveWhitespace || n.NodeType != XmlNodeType.Whitespace)
-						AppendChild (n);
+						AppendChild (n, false);
 				} while (true);
 #if NET_2_0
 				if (xmlReader.Settings != null)
@@ -785,10 +785,10 @@ namespace System.Xml
 		{
 			while (reader.ReadAttributeValue ()) {
 				if (reader.NodeType == XmlNodeType.EntityReference)
-					attribute.AppendChild (CreateEntityReference (reader.Name));
+					attribute.AppendChild (CreateEntityReference (reader.Name), false); // omit node type check
 				else
 					// Children of Attribute is restricted to CharacterData and EntityReference (Comment is not allowed).
-					attribute.AppendChild (CreateTextNode (reader.Value));
+					attribute.AppendChild (CreateTextNode (reader.Value), false); // omit node type check
 			}
 		}
 
@@ -855,7 +855,7 @@ namespace System.Xml
 				while (reader.Depth > depth) {
 					n = ReadNode (reader);
 					if (preserveWhitespace || n.NodeType != XmlNodeType.Whitespace)
-						element.AppendChild (n);
+						element.AppendChild (n, false);
 				}
 				n = element;
 				break;

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

@@ -127,7 +127,7 @@ namespace System.Xml
 					while (FirstChild != null)
 						this.RemoveChild (FirstChild);
 					// creates new Text node
-					AppendChild (OwnerDocument.CreateTextNode (value));
+					AppendChild (OwnerDocument.CreateTextNode (value), false);
 				}
 			}
 		}
@@ -258,7 +258,7 @@ namespace System.Xml
 
 			if (deep) {
 				for (int i = 0; i < ChildNodes.Count; i++)
-					node.AppendChild (ChildNodes [i].CloneNode (true));
+					node.AppendChild (ChildNodes [i].CloneNode (true), false);
 			}
 
 			return node;

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

@@ -325,10 +325,15 @@ namespace System.Xml
 
 		public virtual XmlNode AppendChild (XmlNode newChild)
 		{
-			// I assume that AppendChild(n) equals to InsertAfter(n, this.LastChild) or InsertBefore(n, null)
+			// AppendChild(n) is equivalent to InsertBefore(n, null)
 			return InsertBefore (newChild, null);
 		}
 
+		internal XmlNode AppendChild (XmlNode newChild, bool checkNodeType)
+		{
+			return InsertBefore (newChild, null, checkNodeType, true);
+		}
+
 		public virtual XmlNode Clone ()
 		{
 			// By MS document, it is equivalent to CloneNode(true).