Implementation of XmlDocument.CreateNode()
authorKral Ferch <kral@mono-cvs.ximian.com>
Sat, 6 Apr 2002 04:19:40 +0000 (04:19 -0000)
committerKral Ferch <kral@mono-cvs.ximian.com>
Sat, 6 Apr 2002 04:19:40 +0000 (04:19 -0000)
svn path=/trunk/mcs/; revision=3650

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/XmlAttribute.cs
mcs/class/System.XML/System.Xml/XmlCharacterData.cs
mcs/class/System.XML/System.Xml/XmlDeclaration.cs
mcs/class/System.XML/System.Xml/XmlDocument.cs
mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs
mcs/class/System.XML/System.Xml/XmlWhitespace.cs
mcs/class/System.XML/Test/ChangeLog
mcs/class/System.XML/Test/MonoMicro.Test.csproj
mcs/class/System.XML/Test/XmlDocumentTests.cs

index 6f621e03e68dae5a6c2dd7ce38b537d2f353f69d..659fe086fc5e53f1cc877e6f1b89452877475c8d 100644 (file)
@@ -1,3 +1,22 @@
+2002-04-05  Kral Ferch  <kral_ferch@hotmail.com>
+
+       * XmlAttributes.cs: Added reminder MonoTODO to set NamespaceURI
+       if prefix in constructor is one of the default ones.
+       
+       * XmlCharacterData.cs: Returns String.Empty for Value and Data
+       even when constructed with null.
+       
+       * XmlDeclaration.cs: Value doesn't put encoding or standalone
+       in if they are empty.
+       
+       * XmlDocument.cs: Implemented CreateNode methods and this caused
+       the changes in the other files in this checkin.
+       
+       * XmlProcessingInstruction.cs: Returns String.Empty for Value and Data
+       even when constructed with null.
+       
+       * XmlWhitespace.cs: Changed Value 'get' to return Data.
+
 2002-04-01  Kral Ferch  <kral_ferch@hotmail.com>
 
        * XmlTextWriter.cs: Impls for WriteEndDocument and WriteFullEndElement.
index 0db650d74b0272bb1927b2bc25ee97a07c315dda..054eb655cbc54bfdcd1030a309c7c2cb8b6d07a8 100644 (file)
@@ -25,6 +25,7 @@ namespace System.Xml
 
                #region Constructor
 
+               [MonoTODO("need to set namespaceURI if prefix is recognized built-in ones like xmlns")]
                protected internal XmlAttribute (
                        string prefix, 
                        string localName, 
index 5fc8e20dbe7b5c23c15e93a30ef244433f7c68da..861f1d143eb3ef36bc5ca2fa951785e704635f36 100644 (file)
@@ -20,6 +20,9 @@ namespace System.Xml
                protected internal XmlCharacterData (string data, XmlDocument doc)
                        : base (doc)
                {
+                       if (data == null)
+                               data = String.Empty;
+
                        this.data = data;
                }
 
index 9732d19114f218f1ee2a31df5882ae82fd7d00a4..e1dcf421527bbd175edfae34f7e5ba3402858a5c 100644 (file)
-//\r
-// System.Xml.XmlDeclaration\r
-//\r
-// Author:\r
-//     Duncan Mak  (duncan@ximian.com)\r
-//\r
-// (C) Ximian, Inc.\r
-\r
-using System;\r
-using System.Xml;\r
-\r
-namespace System.Xml\r
-{\r
-       public class XmlDeclaration : XmlLinkedNode\r
-       {\r
-               string encoding = "UTF-8"; // defaults to UTF-8\r
-               string standAlone;\r
-               string version;\r
-\r
-               protected internal XmlDeclaration (string version, string encoding,\r
-                                                  string standAlone, XmlDocument doc)\r
-                       : base (doc)\r
-               {\r
-                       this.version = version;\r
-                       this.encoding = encoding;\r
-                       this.standAlone = standAlone;\r
-               }\r
-\r
-               public string Encoding  {\r
-                       get {\r
-                               if (encoding == null)\r
-                                       return String.Empty;\r
-                               else\r
-                                       return encoding;\r
-                       } \r
-\r
-                       set { encoding = value ; } // Note: MS' doesn't check this string, should we?\r
-               }\r
-\r
-               public override string InnerText {\r
-                       get { return Value; }\r
-                       set { ParseInput (value); }\r
-               }\r
-               \r
-               public override string LocalName {\r
-                       get { return "xml"; }\r
-               }\r
-\r
-               public override string Name {\r
-                       get { return "xml"; }\r
-               }\r
-\r
-               public override XmlNodeType NodeType {\r
-                       get { return XmlNodeType.XmlDeclaration; }\r
-               }\r
-\r
-               public string Standalone {\r
-                       get {\r
-                               if (standAlone == null)\r
-                                       return String.Empty;\r
-                               else\r
-                                       return standAlone;\r
-                       }\r
-\r
-                       set {\r
-                               if (value.ToUpper() == "YES")\r
-                                       standAlone = "yes";\r
-                               if (value.ToUpper() == "NO")\r
-                                       standAlone = "no";\r
-                       }\r
-               }\r
-\r
-               public override string Value {\r
-                       get { return String.Format ("version=\"{0}\" encoding=\"{1}\" standalone=\"{2}\"",\r
-                                                   Version, Encoding, Standalone); }\r
-                       set { ParseInput (value); }\r
-               }\r
-\r
-               public string Version {\r
-                       get { return version; }\r
-               }\r
-\r
-               public override XmlNode CloneNode (bool deep)\r
-               {\r
-                       return new XmlDeclaration (Version, Encoding, standAlone, OwnerDocument);\r
-               }\r
-\r
-               public override void WriteContentTo (XmlWriter w)\r
-               {\r
-                       // Nothing to do - no children.\r
-               }\r
-\r
-               [MonoTODO]\r
-               public override void WriteTo (XmlWriter w)\r
-               {\r
-                       if ((Standalone == String.Empty) || (Encoding == String.Empty))\r
-                               return;\r
-               }\r
-\r
-               void ParseInput (string input)\r
-               {                       \r
-                       Encoding = input.Split (new char [] { ' ' }) [1].Split (new char [] { '=' }) [1];\r
-                       Standalone = input.Split (new char [] { ' ' }) [2].Split (new char [] { '=' }) [1];\r
-               }\r
-       }\r
-}\r
+//
+// System.Xml.XmlDeclaration
+//
+// Author:
+//     Duncan Mak  (duncan@ximian.com)
+//
+// (C) Ximian, Inc.
+
+using System;
+using System.Xml;
+
+namespace System.Xml
+{
+       public class XmlDeclaration : XmlLinkedNode
+       {
+               string encoding = "UTF-8"; // defaults to UTF-8
+               string standalone;
+               string version;
+
+               protected internal XmlDeclaration (string version, string encoding,
+                                                  string standalone, XmlDocument doc)
+                       : base (doc)
+               {
+                       if (encoding == null)
+                               encoding = "";
+
+                       if (standalone == null)
+                               standalone = "";
+
+                       this.version = version;
+                       this.encoding = encoding;
+                       this.standalone = standalone;
+               }
+
+               public string Encoding  {
+                       get { return encoding; } 
+                       set { encoding = (value == null) ? String.Empty : value; }
+               }
+
+               public override string InnerText {
+                       get { return Value; }
+                       set { ParseInput (value); }
+               }
+               
+               public override string LocalName {
+                       get { return "xml"; }
+               }
+
+               public override string Name {
+                       get { return "xml"; }
+               }
+
+               public override XmlNodeType NodeType {
+                       get { return XmlNodeType.XmlDeclaration; }
+               }
+
+               public string Standalone {
+                       get { return standalone; }
+                       set {
+                               if (value.ToUpper() == "YES")
+                                       standalone = "yes";
+                               if (value.ToUpper() == "NO")
+                                       standalone = "no";
+                       }
+               }
+
+               public override string Value {
+                       get {
+                               string formatEncoding = "";
+                               string formatStandalone = "";
+
+                               if (encoding != String.Empty)
+                                       formatEncoding = String.Format (" encoding=\"{0}\"", encoding);
+
+                               if (standalone != String.Empty)
+                                       formatStandalone = String.Format (" standalone=\"{0}\"", standalone);
+
+                               return String.Format ("version=\"{0}\"{1}{2}", Version, formatEncoding, formatStandalone);
+                       }
+                       set { ParseInput (value); }
+               }
+
+               public string Version {
+                       get { return version; }
+               }
+
+               public override XmlNode CloneNode (bool deep)
+               {
+                       return new XmlDeclaration (Version, Encoding, standalone, OwnerDocument);
+               }
+
+               public override void WriteContentTo (XmlWriter w)
+               {
+                       // Nothing to do - no children.
+               }
+
+               [MonoTODO]
+               public override void WriteTo (XmlWriter w)
+               {
+                       if ((Standalone == String.Empty) || (Encoding == String.Empty))
+                               return;
+               }
+
+               void ParseInput (string input)
+               {                       
+                       Encoding = input.Split (new char [] { ' ' }) [1].Split (new char [] { '=' }) [1];
+                       Standalone = input.Split (new char [] { ' ' }) [2].Split (new char [] { '=' }) [1];
+               }
+       }
+}
index 0fd361d683f2585a7dd61f13131f8049427f6262..15c5e641d2b851b36064797e3df66c3f63e9290d 100644 (file)
@@ -150,33 +150,25 @@ namespace System.Xml
                [MonoTODO]
                public XmlAttribute CreateAttribute (string name)
                {
-                       int indexOfColon = name.IndexOf (':');
-                       
-                       if (indexOfColon == -1)
-                               return CreateAttribute (String.Empty, name, String.Empty);
-
-                       string prefix = name.Substring (0, indexOfColon);
-                       string localName = name.Substring (indexOfColon + 1);
-
-                       return CreateAttribute (prefix, localName, String.Empty);
+                       return CreateAttribute (name, String.Empty);
                }
 
                [MonoTODO]
                public XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
                {
-                       int indexOfColon = qualifiedName.IndexOf (':');
-                       
-                       if (indexOfColon == -1)
-                               return CreateAttribute (String.Empty, qualifiedName, String.Empty);
+                       string prefix;
+                       string localName;
 
-                       string prefix = qualifiedName.Substring (0, indexOfColon);
-                       string localName = qualifiedName.Substring (indexOfColon + 1);
+                       ParseName (qualifiedName, out prefix, out localName);
 
-                       return CreateAttribute (prefix, localName, String.Empty);
+                       return CreateAttribute (prefix, localName, namespaceURI);
                }
 
                public virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
                {
+                       if ((localName == null) || (localName == String.Empty))
+                               throw new ArgumentException ("The attribute local name cannot be empty.");
+
                        return new XmlAttribute (prefix, localName, namespaceURI, this);
                }
 
@@ -210,29 +202,17 @@ namespace System.Xml
 
                public XmlElement CreateElement (string name)
                {
-                       int indexOfColon = name.IndexOf (':');
-                       
-                       if (indexOfColon == -1)
-                               return CreateElement (String.Empty, name, String.Empty);
-
-                       string prefix = name.Substring (0, indexOfColon);
-                       string localName = name.Substring (indexOfColon + 1);
-
-                       return CreateElement (prefix, localName, String.Empty);
+                       return CreateElement (name, String.Empty);
                }
 
-               [MonoTODO]
                public XmlElement CreateElement (
                        string qualifiedName, 
                        string namespaceURI)
                {
-                       int indexOfColon = qualifiedName.IndexOf (':');
-                       
-                       if (indexOfColon == -1)
-                               return CreateElement (String.Empty, qualifiedName, namespaceURI);
+                       string prefix;
+                       string localName;
 
-                       string prefix = qualifiedName.Substring (0, indexOfColon);
-                       string localName = qualifiedName.Substring (indexOfColon + 1);
+                       ParseName (qualifiedName, out prefix, out localName);
 
                        return CreateElement (prefix, localName, namespaceURI);
                }
@@ -242,6 +222,9 @@ namespace System.Xml
                        string localName,
                        string namespaceURI)
                {
+                       if ((localName == null) || (localName == String.Empty))
+                               throw new ArgumentException ("The local name for elements or attributes cannot be null or an empty string.");
+
                        return new XmlElement (prefix, localName, namespaceURI, this);
                }
 
@@ -257,32 +240,51 @@ namespace System.Xml
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public virtual XmlNode CreateNode (
                        string nodeTypeString,
                        string name,
                        string namespaceURI)
                {
-                       throw new NotImplementedException ();
+                       return CreateNode (GetNodeTypeFromString (nodeTypeString), name, namespaceURI);
                }
 
-               [MonoTODO]
                public virtual XmlNode CreateNode (
                        XmlNodeType type,
                        string name,
                        string namespaceURI)
                {
-                       throw new NotImplementedException ();
+                       string prefix = null;
+                       string localName = name;
+
+                       if ((type == XmlNodeType.Attribute) || (type == XmlNodeType.Element) || (type == XmlNodeType.EntityReference))
+                               ParseName (name, out prefix, out localName);
+                       
+                       return CreateNode (type, prefix, localName, namespaceURI);
                }
 
-               [MonoTODO]
                public virtual XmlNode CreateNode (
                        XmlNodeType type,
                        string prefix,
                        string name,
                        string namespaceURI)
                {
-                       throw new NotImplementedException ();
+                       switch (type) {
+                               case XmlNodeType.Attribute: return CreateAttribute (prefix, name, namespaceURI);
+                               case XmlNodeType.CDATA: return CreateCDataSection (null);
+                               case XmlNodeType.Comment: return CreateComment (null);
+                               case XmlNodeType.Document: return new XmlDocument (); // TODO - test to see which constructor to use, i.e. use existing NameTable or not.
+                               case XmlNodeType.DocumentFragment: return CreateDocumentFragment ();
+                               case XmlNodeType.DocumentType: return CreateDocumentType (null, null, null, null);
+                               case XmlNodeType.Element: return CreateElement (prefix, name, namespaceURI);
+                               case XmlNodeType.EntityReference: return CreateEntityReference (null);
+                               case XmlNodeType.ProcessingInstruction: return CreateProcessingInstruction (null, null);
+                               case XmlNodeType.SignificantWhitespace: return CreateSignificantWhitespace (String.Empty);
+                               case XmlNodeType.Text: return CreateTextNode (null);
+                               case XmlNodeType.Whitespace: return CreateWhitespace (String.Empty);
+                               case XmlNodeType.XmlDeclaration: return CreateXmlDeclaration ("1.0", null, null);
+                               default: throw new ArgumentOutOfRangeException(String.Format("{0}\nParameter name: {1}",
+                                                        "Specified argument was out of the range of valid values", type.ToString ()));
+                       }
                }
 
                public virtual XmlProcessingInstruction CreateProcessingInstruction (
@@ -345,6 +347,26 @@ namespace System.Xml
                        throw new NotImplementedException();
                }
 
+               private XmlNodeType GetNodeTypeFromString (string nodeTypeString)
+               {
+                       switch (nodeTypeString) {
+                               case "attribute": return XmlNodeType.Attribute;
+                               case "cdatasection": return XmlNodeType.CDATA;
+                               case "comment": return XmlNodeType.Comment;
+                               case "document": return XmlNodeType.Document;
+                               case "documentfragment": return XmlNodeType.DocumentFragment;
+                               case "documenttype": return XmlNodeType.DocumentType;
+                               case "element": return XmlNodeType.Element;
+                               case "entityreference": return XmlNodeType.EntityReference;
+                               case "processinginstruction": return XmlNodeType.ProcessingInstruction;
+                               case "significantwhitespace": return XmlNodeType.SignificantWhitespace;
+                               case "text": return XmlNodeType.Text;
+                               case "whitespace": return XmlNodeType.Whitespace;
+                               default:
+                                       throw new ArgumentException(String.Format("The string doesn't represent any node type : {0}.", nodeTypeString));
+                       }
+               }
+
                [MonoTODO]
                public virtual XmlNode ImportNode (XmlNode node, bool deep)
                {
@@ -481,6 +503,19 @@ namespace System.Xml
                                        node, oldParent, null));
                }
 
+               private void ParseName (string name, out string prefix, out string localName)
+               {
+                       int indexOfColon = name.IndexOf (':');
+                       
+                       if (indexOfColon != -1) {
+                               prefix = name.Substring (0, indexOfColon);
+                               localName = name.Substring (indexOfColon + 1);
+                       } else {
+                               prefix = "";
+                               localName = name;
+                       }
+               }
+
                [MonoTODO]
                public virtual XmlNode ReadNode(XmlReader reader)
                {
index f9a1f2e607c614db5c33264f06ee41ff76054404..c328935a7feb8f44cf52a6dd55e98d3cef4a1df7 100644 (file)
@@ -20,6 +20,9 @@ namespace System.Xml
 
                protected internal XmlProcessingInstruction (string target, string data, XmlDocument doc) : base(doc)
                {
+                       if (data == null)
+                               data = String.Empty;
+
                        this.target = target;
                        this.data = data;
                }
index c49d880360b79a736cc90243badc758b4d036c32..610ec9c7d54fa38a7af512947ee3d083e26a25cf 100644 (file)
@@ -1,58 +1,58 @@
-//\r
-// System.Xml.XmlWhitespace.cs\r
-//\r
-// Author:\r
-//     Duncan Mak  (duncan@ximian.com)\r
-//\r
-// (C) Ximian, Inc. http://www.ximian.com\r
-//\r
-\r
-using System;\r
-\r
-namespace System.Xml\r
-{\r
-       public class XmlWhitespace : XmlCharacterData\r
-       {\r
-               // Constructor\r
-               protected internal XmlWhitespace (string strData, XmlDocument doc)\r
-                       : base (strData, doc)\r
-               {\r
-               }\r
-               \r
-               // Properties\r
-               public override string LocalName {\r
-                       get { return "#whitespace"; }\r
-               }\r
-\r
-               public override string Name {\r
-                       get { return "#whitespace"; }\r
-               }\r
-\r
-               public override XmlNodeType NodeType {\r
-                       get { return XmlNodeType.Whitespace; }\r
-               }\r
-\r
-               [MonoTODO]\r
-               public override string Value {\r
-                       get { return null; }\r
-                       set {}\r
-               }\r
-\r
-               // Methods\r
-               public override XmlNode CloneNode (bool deep)\r
-               {\r
-                       // always return the data value\r
-                       return new XmlWhitespace (Data, OwnerDocument); \r
-               }\r
-\r
-               [MonoTODO]\r
-               public override void WriteContentTo (XmlWriter w)\r
-               {                       \r
-               }\r
-\r
-               [MonoTODO]\r
-               public override void WriteTo (XmlWriter w)\r
-               {                       \r
-               }\r
-       }\r
-}\r
+//
+// System.Xml.XmlWhitespace.cs
+//
+// Author:
+//     Duncan Mak  (duncan@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+
+namespace System.Xml
+{
+       public class XmlWhitespace : XmlCharacterData
+       {
+               // Constructor
+               protected internal XmlWhitespace (string strData, XmlDocument doc)
+                       : base (strData, doc)
+               {
+               }
+               
+               // Properties
+               public override string LocalName {
+                       get { return "#whitespace"; }
+               }
+
+               public override string Name {
+                       get { return "#whitespace"; }
+               }
+
+               public override XmlNodeType NodeType {
+                       get { return XmlNodeType.Whitespace; }
+               }
+
+               [MonoTODO]
+               public override string Value {
+                       get { return Data; }
+                       set {}
+               }
+
+               // Methods
+               public override XmlNode CloneNode (bool deep)
+               {
+                       // always return the data value
+                       return new XmlWhitespace (Data, OwnerDocument); 
+               }
+
+               [MonoTODO]
+               public override void WriteContentTo (XmlWriter w)
+               {                       
+               }
+
+               [MonoTODO]
+               public override void WriteTo (XmlWriter w)
+               {                       
+               }
+       }
+}
index aafb75fbf8816af0298aacf575767ffd46b8ef7d..c81b68c5514fb82026b25c54829b254362a4aafa 100644 (file)
@@ -1,3 +1,7 @@
+2002-04-05  Kral Ferch  <kral_ferch@hotmail.com>
+
+       * XmlDocumentTests.cs: CreateNode tests.
+
 2002-04-01  Kral Ferch  <kral_ferch@hotmail.com>
 
        * XmlTextWriterTests.cs: Tests for WriteEndDocument and WriteFullEndElement.
index 85f3a91180f04d2ed4dcf6fbcd20c676b285bd80..80c2a6bfdd9524fa69ada997014892039c81ce27 100644 (file)
@@ -70,7 +70,7 @@
                 <Reference
                     Name = "System.XML"
                     AssemblyName = "System.XML"
-                    HintPath = "..\obj\Debug\System.XML.dll"
+                    HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
                 />
             </References>
         </Build>
index a72d1526d2ef13cd57446a864f74f0c578ec33b3..ffe822b4d02de7238648c63f98b2381162841b0a 100644 (file)
@@ -17,6 +17,160 @@ namespace Ximian.Mono.Tests
                        document = new XmlDocument ();
                }
 
+               public void TestCreateNodeNodeTypeNameEmptyParams ()
+               {
+                       XmlNode node;
+
+                       try {
+                               node = document.CreateNode (null, null, null);
+                               Fail ("Expected an ArgumentException to be thrown.");
+                       } catch (ArgumentException) {}
+
+                       try {
+                               node = document.CreateNode ("attribute", null, null);
+                               Fail ("Expected a NullReferenceException to be thrown.");
+                       } catch (NullReferenceException) {}
+
+                       try {
+                               node = document.CreateNode ("attribute", "", null);
+                               Fail ("Expected an ArgumentException to be thrown.");
+                       } catch (ArgumentException) {}
+
+                       try {
+                               node = document.CreateNode ("element", null, null);
+                               Fail ("Expected a NullReferenceException to be thrown.");
+                       } catch (NullReferenceException) {}
+
+                       try {
+                               node = document.CreateNode ("element", "", null);
+                               Fail ("Expected an ArgumentException to be thrown.");
+                       } catch (ArgumentException) {}
+
+                       try {
+                               node = document.CreateNode ("entityreference", null, null);
+                               Fail ("Expected a NullReferenceException to be thrown.");
+                       } catch (NullReferenceException) {}
+               }
+
+               public void TestCreateNodeInvalidXmlNodeType ()
+               {
+                       XmlNode node;
+
+                       try {
+                               node = document.CreateNode (XmlNodeType.EndElement, null, null);
+                               Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+                       } catch (ArgumentOutOfRangeException) {}
+
+                       try {
+                               node = document.CreateNode (XmlNodeType.EndEntity, null, null);
+                               Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+                       } catch (ArgumentOutOfRangeException) {}
+
+                       try {
+                               node = document.CreateNode (XmlNodeType.Entity, null, null);
+                               Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+                       } catch (ArgumentOutOfRangeException) {}
+
+                       try {
+                               node = document.CreateNode (XmlNodeType.None, null, null);
+                               Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+                       } catch (ArgumentOutOfRangeException) {}
+
+                       try {
+                               node = document.CreateNode (XmlNodeType.Notation, null, null);
+                               Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
+                       } catch (ArgumentOutOfRangeException) {}
+
+                       // TODO:  undocumented allowable type.
+                       node = document.CreateNode (XmlNodeType.XmlDeclaration, null, null);
+                       AssertEquals (XmlNodeType.XmlDeclaration, node.NodeType);
+               }
+
+               public void TestCreateNodeWhichParamIsUsed ()
+               {
+                       XmlNode node;
+
+                       // No constructor params for Document, DocumentFragment.
+
+                       node = document.CreateNode (XmlNodeType.CDATA, "a", "b", "c");
+                       AssertEquals (String.Empty, ((XmlCDataSection)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.Comment, "a", "b", "c");
+                       AssertEquals (String.Empty, ((XmlComment)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.DocumentType, "a", "b", "c");
+                       AssertNull (((XmlDocumentType)node).Value);
+
+// TODO: add this back in to test when it's implemented.
+//                     node = document.CreateNode (XmlNodeType.EntityReference, "a", "b", "c");
+//                     AssertNull (((XmlEntityReference)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.ProcessingInstruction, "a", "b", "c");
+                       AssertEquals (String.Empty, ((XmlProcessingInstruction)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.SignificantWhitespace, "a", "b", "c");
+                       AssertEquals (String.Empty, ((XmlSignificantWhitespace)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.Text, "a", "b", "c");
+                       AssertEquals (String.Empty, ((XmlText)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.Whitespace, "a", "b", "c");
+                       AssertEquals (String.Empty, ((XmlWhitespace)node).Value);
+
+                       node = document.CreateNode (XmlNodeType.XmlDeclaration, "a", "b", "c");
+                       AssertEquals ("version=\"1.0\"", ((XmlDeclaration)node).Value);
+               }
+
+               public void TestCreateNodeNodeTypeName ()
+               {
+                       XmlNode node;
+
+                       try {
+                               node = document.CreateNode ("foo", null, null);
+                               Fail ("Expected an ArgumentException to be thrown.");
+                       } catch (ArgumentException) {}
+
+                       node = document.CreateNode("attribute", "foo", null);
+                       AssertEquals (XmlNodeType.Attribute, node.NodeType);
+
+                       node = document.CreateNode("cdatasection", null, null);
+                       AssertEquals (XmlNodeType.CDATA, node.NodeType);
+
+                       node = document.CreateNode("comment", null, null);
+                       AssertEquals (XmlNodeType.Comment, node.NodeType);
+
+                       node = document.CreateNode("document", null, null);
+                       AssertEquals (XmlNodeType.Document, node.NodeType);
+                       // TODO: test which constructor this ended up calling,
+                       // i.e. reuse underlying NameTable or not?
+
+// TODO: add this back in to test when it's implemented.
+//                     node = document.CreateNode("documentfragment", null, null);
+//                     AssertEquals (XmlNodeType.DocumentFragment, node.NodeType);
+
+                       node = document.CreateNode("documenttype", null, null);
+                       AssertEquals (XmlNodeType.DocumentType, node.NodeType);
+
+                       node = document.CreateNode("element", "foo", null);
+                       AssertEquals (XmlNodeType.Element, node.NodeType);
+
+// TODO: add this back in to test when it's implemented.
+//                     node = document.CreateNode("entityreference", "foo", null);
+//                     AssertEquals (XmlNodeType.EntityReference, node.NodeType);
+
+                       node = document.CreateNode("processinginstruction", null, null);
+                       AssertEquals (XmlNodeType.ProcessingInstruction, node.NodeType);
+
+                       node = document.CreateNode("significantwhitespace", null, null);
+                       AssertEquals (XmlNodeType.SignificantWhitespace, node.NodeType);
+
+                       node = document.CreateNode("text", null, null);
+                       AssertEquals (XmlNodeType.Text, node.NodeType);
+
+                       node = document.CreateNode("whitespace", null, null);
+                       AssertEquals (XmlNodeType.Whitespace, node.NodeType);
+               }
+
                public void TestDocumentElement ()
                {
                        AssertNull (document.DocumentElement);