Browse Source

Got attributes and text nodes working while loading a document.

svn path=/trunk/mcs/; revision=2848
Jason Diamond 24 years ago
parent
commit
b85325090c

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

@@ -1,3 +1,18 @@
+2002-03-02  Jason Diamond <[email protected]>
+
+	* XmlTextReader.cs: Implemented MoveToNextAttribute().
+
+	* XmlDocument.cs: Reformatted. Adding missing methods and MonoTODO
+	attributes. Create attribute nodes while loading. Implemented
+	Load(string) and CreateTextNode().
+
+	* XmlCharacterData.cs, XmlText.cs: Re-implemented.
+
+	* XmlCDataSection.cs, XmlComment.cs: Call correct constructor in 
+	XmlCharacterData.
+
+	* XmlNamedNodeMap.cs, XmlAttributeCollection.cs: Stubbed out.
+
 2002-03-02  Mike Kestner <[email protected]>
 
 	* XmlAttribute.cs : Using fix.

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

@@ -1,146 +1,146 @@
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
-//
-// System.Xml.XmlAttribute
-//
-// Author:
-//   Daniel Weber ([email protected])
-//
-// (C) 2001 Daniel Weber
-
-using System;
-
-namespace System.Xml
-{
-	/// <summary>
-	/// Summary description for XmlAttribute.
-	/// </summary>
-	public class XmlAttribute : XmlNode
-	{
-		// ============  private data structures ==============================
-		private XmlNode FOwnerElement;
-		
-		string FattrName;
-		string FattrValue;
-		
-		//==== Public Properties ====================================================
-
-		/// <summary>
-		/// Returns the local name of the attribute.  For attributes, this is the same as Name
-		/// </summary>
-		public override string LocalName 
-		{
-			get
-			{
-				return Name;
-			}
-		}
-
-		/// <summary>
-		/// Get the qualified attribute name.  Attributes do not have an associated namespace.
-		/// </summary>
-		public override string Name 
-		{ 
-			get
-			{
-				return Name;
-			}
-		}
-
-		/// <summary>
-		/// Override.  Returns the node type.
-		/// </summary>
-		public override XmlNodeType NodeType 
-		{
-			get
-			{
-				return XmlNodeType.Attribute;
-			}
-		}
-
-		/// <summary>
-		/// Retrieve the XmlElement owner of this attribute, or null if attribute not assigned
-		/// </summary>
-		public virtual XmlElement OwnerElement
-		{
-			get
-			{
-				if (FOwnerElement.NodeType == XmlNodeType.Element)
-					return FOwnerElement as XmlElement;
-				else
-					return null;
-			}
-		}
-
-		/// <summary>
-		/// Get/Set the value for this node
-		/// </summary>
-		public override string Value 
-		{
-			get
-			{
-				return FattrValue;
-			}
-			
-			set
-			{
-				FattrValue = value;
-			}
-		}
-
-		//============== Public Methods =============================================
-
-		/// <summary>
-		/// Return a clone of the node
-		/// </summary>
-		/// <param name="deep">Make copy of all children</param>
-		/// <returns>Cloned node</returns>
-		public override XmlNode CloneNode( bool deep)
-		{
-			// TODO - implement XmlAttribute.CloneNode()
-			throw new NotImplementedException();
-		}
-
-		/// <summary>
-		/// Saves all children of the current node to the passed writer
-		/// </summary>
-		/// <param name="w"></param>
-		public override void WriteContentTo(XmlWriter w)
-		{
-			// TODO - implement XmlAttribute.WriteContentsTo(XmlWriter)
-			throw new NotImplementedException();
-		}
-
-		/// <summary>
-		/// Saves the current node to writer w
-		/// </summary>
-		/// <param name="w"></param>
-		public override void WriteTo(XmlWriter w)
-		{
-			// TODO - implement XmlAttribute.WriteTo(XmlWriter)
-			throw new NotImplementedException();
-		}
-
-		// ============  Internal methods  ====================================
-		internal void setOwnerElement( XmlElement newOwnerElement)
-		{
-			FOwnerElement = newOwnerElement;
-		}
-
-		// ============  Constructors =========================================
-		internal XmlAttribute ( XmlDocument aOwner,			// owner document
-			string attributeName,							// cannot be ""
-			string attValue) : base(aOwner)
-		{
-			if (aOwner == null)
-				throw new ArgumentException("Null OwnerDocument passed to XmlAttribute constructor");
-			if (attributeName.Length == 0)
-				throw new ArgumentException("Empty string passed to XmlAttribute constructor");
-
-			FOwnerElement = null;
-			FattrName = attributeName;
-			FattrValue = attValue;
-		}
-	
-
-	}
-}
+// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+//
+// System.Xml.XmlAttribute
+//
+// Author:
+//   Daniel Weber ([email protected])
+//
+// (C) 2001 Daniel Weber
+
+using System;
+
+namespace System.Xml
+{
+	/// <summary>
+	/// Summary description for XmlAttribute.
+	/// </summary>
+	public class XmlAttribute : XmlNode
+	{
+		// ============  private data structures ==============================
+		private XmlNode FOwnerElement;
+		
+		string FattrName;
+		string FattrValue;
+		
+		//==== Public Properties ====================================================
+
+		/// <summary>
+		/// Returns the local name of the attribute.  For attributes, this is the same as Name
+		/// </summary>
+		public override string LocalName 
+		{
+			get
+			{
+				return FattrName;
+			}
+		}
+
+		/// <summary>
+		/// Get the qualified attribute name.  Attributes do not have an associated namespace.
+		/// </summary>
+		public override string Name 
+		{ 
+			get
+			{
+				return FattrName;
+			}
+		}
+
+		/// <summary>
+		/// Override.  Returns the node type.
+		/// </summary>
+		public override XmlNodeType NodeType 
+		{
+			get
+			{
+				return XmlNodeType.Attribute;
+			}
+		}
+
+		/// <summary>
+		/// Retrieve the XmlElement owner of this attribute, or null if attribute not assigned
+		/// </summary>
+		public virtual XmlElement OwnerElement
+		{
+			get
+			{
+				if (FOwnerElement.NodeType == XmlNodeType.Element)
+					return FOwnerElement as XmlElement;
+				else
+					return null;
+			}
+		}
+
+		/// <summary>
+		/// Get/Set the value for this node
+		/// </summary>
+		public override string Value 
+		{
+			get
+			{
+				return FattrValue;
+			}
+			
+			set
+			{
+				FattrValue = value;
+			}
+		}
+
+		//============== Public Methods =============================================
+
+		/// <summary>
+		/// Return a clone of the node
+		/// </summary>
+		/// <param name="deep">Make copy of all children</param>
+		/// <returns>Cloned node</returns>
+		public override XmlNode CloneNode( bool deep)
+		{
+			// TODO - implement XmlAttribute.CloneNode()
+			throw new NotImplementedException();
+		}
+
+		/// <summary>
+		/// Saves all children of the current node to the passed writer
+		/// </summary>
+		/// <param name="w"></param>
+		public override void WriteContentTo(XmlWriter w)
+		{
+			// TODO - implement XmlAttribute.WriteContentsTo(XmlWriter)
+			throw new NotImplementedException();
+		}
+
+		/// <summary>
+		/// Saves the current node to writer w
+		/// </summary>
+		/// <param name="w"></param>
+		public override void WriteTo(XmlWriter w)
+		{
+			// TODO - implement XmlAttribute.WriteTo(XmlWriter)
+			throw new NotImplementedException();
+		}
+
+		// ============  Internal methods  ====================================
+		internal void setOwnerElement( XmlElement newOwnerElement)
+		{
+			FOwnerElement = newOwnerElement;
+		}
+
+		// ============  Constructors =========================================
+		internal XmlAttribute ( XmlDocument aOwner,			// owner document
+			string attributeName,							// cannot be ""
+			string attValue) : base(aOwner)
+		{
+			if (aOwner == null)
+				throw new ArgumentException("Null OwnerDocument passed to XmlAttribute constructor");
+			if (attributeName.Length == 0)
+				throw new ArgumentException("Empty string passed to XmlAttribute constructor");
+
+			FOwnerElement = null;
+			FattrName = attributeName;
+			FattrValue = attValue;
+		}
+	
+
+	}
+}

+ 117 - 506
mcs/class/System.XML/System.Xml/XmlAttributeCollection.cs

@@ -1,506 +1,117 @@
-// System.Xml.XmlAttributeCollection.cs
-//
-// Author: Daniel Weber ([email protected])
-//
-// Implementation of abstract Xml.XmlAttributeCollection class
-//
-
-using System;
-using System.Collections;
-
-namespace System.Xml
-{
-	/// <summary>
-	/// A collection of Attributes that can be accessed by index or name(space)
-	/// Derived from XmlNamedNodeMap
-	/// <seealso cref="XmlNamedNodeMap"/>
-	/// </summary>
-	public class XmlAttributeCollection : XmlNamedNodeMap, ICollection
-	{
-
-		// =====  ICollection interface elements  ===================================
-		/// <summary>
-		/// Private class to provide Synchronzed Access to the attribute list.
-		/// </summary>
-		private class SyncAttributes : XmlAttributeCollection
-		{
-			private XmlAttributeCollection _attributes;
-
-			public SyncAttributes ( XmlAttributeCollection attributes )
-			{
-				_attributes = attributes;
-			}
-
-			public override bool IsSynchronized 
-			{
-				get {return true; }
-			}
-
-			// Override all properties/methods that modify/read items
-			//	and lock them so they are thread-safe
-			public override void CopyTo(Array array, int index)
-			{
-				lock (_attributes )
-				{ _attributes.CopyTo(array, index); }
-			}
-			
-			public override XmlAttribute this[string name] 
-			{
-				get  {
-					lock (_attributes ) { return _attributes[name]; }
-				}
-			}
-
-			public override XmlAttribute this[int i] 
-			{
-				get {
-					lock (_attributes) { return _attributes[i]; }
-				}
-			}
-
-			public override XmlAttribute Append( XmlAttribute node )
-			{
-				lock (_attributes)
-				{ return _attributes.Append( node ); }
-			}
-			
-			public override void CopyTo(XmlAttribute[] array, int index)
-			{
-				lock (_attributes)
-				{ _attributes.CopyTo(array, index); }
-			}
-
-			public override XmlAttribute InsertAfter( 
-				XmlAttribute newNode, 
-				XmlAttribute refNode)
-			{
-				lock (_attributes)
-				{ return _attributes.InsertAfter( newNode, refNode ); }
-			}
-
-			public override XmlAttribute Prepend(XmlAttribute node)
-			{
-				lock (_attributes)
-				{ return _attributes.Prepend(node); }
-			}
-
-			public override XmlAttribute Remove(XmlAttribute node)
-			{
-				lock (_attributes)
-				{ return _attributes.Remove( node ); }
-			}
-
-			public override void RemoveAll()
-			{
-				lock (_attributes)
-				{ _attributes.RemoveAll(); }
-			}
-
-			public override XmlAttribute RemoveAt(int i)
-			{
-				lock (_attributes)
-				{ return _attributes.RemoveAt(i); }
-			}
-
-			public override XmlNode SetNamedItem(XmlNode node)
-			{
-				lock (_attributes)
-				{ return _attributes.SetNamedItem(node); }
-			}
-
-			// Even ToString, since someone could come along and blow away an
-			//	attribute while we're iterating...
-			public override string ToString()
-			{
-				lock (_attributes) 
-				{ return _attributes.ToString(); }
-			}
-
-		}  // SynchAttributes
-
-		/// <summary>
-		/// Return true if access is synchronized (thread-safe)
-		/// </summary>
-		public virtual bool IsSynchronized 
-		{
-			// This version of the class is not synchronized
-			get
-			{
-				return false;
-			}
-		}
-
-		/// <summary>
-		/// Return object used for synchronous access to class
-		/// </summary>
-		public object SyncRoot 
-		{
-			get
-			{
-				return this;
-			}
-		}
-
-		/// <summary>
-		/// Returns a thread-safe version of the attribute collection.
-		/// </summary>
-		/// <param name="attributes">Attribute collection to make thread-safe.</param>
-		/// <returns>Thread-safe XmlAttributeCollection.</returns>
-		public static XmlAttributeCollection Synchronized(XmlAttributeCollection attributes) 
-		{
-			if (attributes == null) 
-			{
-				throw new ArgumentNullException("Null XmlAttributeCollection passed to Synchronized()");
-			}
-
-			return new SyncAttributes(attributes);
-		}
-
-		/// <summary>
-		/// Copy the XmlAttributeCollection into the passed array.  Index is zero-based.
-		/// </summary>
-		/// <param name="array">Array to copy into</param>
-		/// <param name="index">Index to start copying from</param>
-		public virtual void CopyTo(Array array, int index)
-		{
-			// Let the Array handle all the errors, there's no risk to us
-
-			// TODO - should we set OwnerElement to null in clone() in CopyTo(Array, int)? (yes, using setOwnerElement())
-			int arrayIndex = 0;
-			for (int i = index; i < FnodeList.Count; i++)
-			{
-				XmlAttribute e = FnodeList[i] as XmlAttribute;
-				XmlAttribute theClone = e.Clone() as XmlAttribute;
-				theClone.setOwnerElement(null);
-				array.SetValue(theClone, arrayIndex);
-				arrayIndex++;
-			}
-		}
-		// XmlAttributeCollection Properties =================================
-		/// <summary>
-		/// Get the attribute with the specified name
-		/// </summary>
-		[System.Runtime.CompilerServices.IndexerName("ItemOf")]
-		public virtual XmlAttribute this[string name] 
-		{
-			get
-			{
-				return GetNamedItem(name) as XmlAttribute;
-			}
-		}
-
-		/// <summary>
-		/// Get the attribute at the specified index.  The Collection is zero-based.
-		/// </summary>
-		[System.Runtime.CompilerServices.IndexerName("ItemOf")]
-		public virtual XmlAttribute this[int i] 
-		{
-			get
-			{
-				return base.Item(i) as XmlAttribute;
-			}
-		}
-
-		/// <summary>
-		/// Get the attribute with the specifed (localName, URI)
-		/// </summary>
-		[System.Runtime.CompilerServices.IndexerName("ItemOf")]
-		public virtual XmlAttribute this[string localName, string namespaceURI] 
-		{
-			get
-			{
-				return GetNamedItem(localName, namespaceURI) as XmlAttribute;
-			}
-		}
-
-		// ============= Public methods =====================================
-		/// <summary>
-		/// Appends the specified node to the attribute list
-		/// If the node is already in the list, it is moved to the end.
-		/// If a node is in the list with the same name, the node is removed and the new node is added.
-		/// </summary>
-		/// <param name="node">Attribute node to append to the collection</param>
-		/// <exception cref="ArgumentException">Node was created from a differant document or node is null</exception>
-		/// <returns></returns>
-		public virtual XmlAttribute Append( XmlAttribute node )
-		{
-			// TODO - node validation? (no)
-			
-			XmlAttribute retval = null;
-
-			System.Diagnostics.Debug.Assert(node != null, "Null node passed to Append()");
-
-			if (! FOwner.OwnerDocument.Equals(node.OwnerDocument))
-				throw new ArgumentException("Cannot append node from another document");
-
-			if (node.OwnerElement != null) 
-				throw new ArgumentException("Cannot append node from another document");
-
-			foreach (XmlAttribute cur in FnodeList)
-			{
-				// If node is already in the collection, it is moved to the last position. 
-				if (cur.Equals(node))
-				{
-					retval = cur;
-					FnodeList.Remove(cur);
-				}
-
-				//If an attribute with the same name is already present in the collection, 
-				//   the original attribute is removed from the collection and 
-				//   node is added to the end of the collection.
-				if (cur.Name == node.Name)
-					FnodeList.Remove(cur);
-			}
-
-			// add the new node to the end of the collection
-			// set attribute owner element? (yes)
-			node.setOwnerElement(FOwnerNode as XmlElement);
-			FnodeList.Add(node);
-
-			// return the removed item
-			return retval;
-		}
-
-		/// <summary>
-		/// Copies all attributes in collection into the array, starting at index.
-		/// attribute index is zero-based.
-		/// </summary>
-		/// <exception cref="OverflowException">Thrown if insufficient room to copy all elements</exception>
-		/// <param name="array">Array to copy XlmAttributes into</param>
-		/// <param name="index">index to start copy</param>
-		public virtual void CopyTo(XmlAttribute[] array, int index)
-		{
-			// Let the array handle all the errors, there's no risk to us
-
-			// TODO - should we set OwnerElement to null in clone() in CopyTo(XmlAttribute[], int)? (yes, using setOwnerElement())
-			int arrayIndex = 0;
-			for (int i = index; i < FnodeList.Count; i++)
-			{
-				XmlAttribute e = FnodeList[i] as XmlAttribute;
-				XmlAttribute theClone = e.Clone() as XmlAttribute;
-				theClone.setOwnerElement(null);
-				array[arrayIndex] = theClone;
-				arrayIndex++;
-			}
-		}
-
-		/// <summary>
-		/// Helper function since InsertBefore/After use exact same algorithm
-		/// </summary>
-		/// <param name="refNode"></param>
-		/// <param name="newNode"></param>
-		/// <param name="offset">offset to add to Insert (0 or 1)</param>
-		/// <returns>Deleted attribute</returns>
-		private XmlAttribute InsertHelper(XmlAttribute newNode, XmlAttribute refNode, int offset)
-		{
-			// TODO - validation? (no)
-			// TODO - null refNode is valid (== prepend)
-			if (refNode == null)
-				throw new ArgumentNullException("Null refNode passed to InsertAfter()");
-			if (newNode == null)
-				throw new ArgumentNullException("Null newNode passed to InsertAfter()");
-
-			if (! newNode.OwnerDocument.Equals(FOwner.OwnerDocument) )
-				throw new ArgumentException("Node to insert does not have same owner document as reference");
-
-			// Logically, it makes no sense to insert node "A" after node "A",
-			//	since only one node "A" can be in the list - flag it as an error
-			if (newNode.Name == refNode.Name)
-				throw new ArgumentException("Node to insert has same name as reference node");
-
-			// Other bizarre case is if refNode.Equals(newNode)
-			//	We'll flag this error after we check that refNode is in the list
-		
-			int refNodeIndex = -1;
-			// Note that if newNode is in the list, then we'll get a name match
-			int SameNameIndex = -1;
-
-			for (int i = 0; i < FnodeList.Count; i++)
-			{
-				XmlAttribute curListNode = Item(i) as XmlAttribute;
-				if (curListNode.Name == refNode.Name)
-					refNodeIndex = i;
-				
-				if (curListNode.Name == newNode.Name)
-					SameNameIndex = i;
-			}
-
-			if ( refNodeIndex == -1 )
-				throw new ArgumentException("Attribute [" + refNode.Name + "] is not in Collection for InsertAfter()");
-
-			// Check the obvious, InsertAfter( attr1, attr1);
-			if (refNode.Equals( newNode ) )
-				return newNode;
-
-			XmlAttribute retval = null;
-
-			if (SameNameIndex != -1)
-			{
-				// If this is newNode in the list, we'll insert it back in the right spot
-				// If this is another node, just remove it
-				retval = FnodeList[SameNameIndex] as XmlAttribute;
-				FnodeList.RemoveAt(SameNameIndex);
-				if ( SameNameIndex < refNodeIndex )
-					refNodeIndex--;
-			}
-
-			FnodeList.Insert(refNodeIndex + offset, newNode);
-
-			// TODO - set OwnerElement? (no)
-			//node.setOwnerElement(FOwnerNode as XmlElement);
-
-			// TODO - determine which node to return (deleted node)
-			return retval;
-		}
-
-		/// <summary>
-		/// Insert the specifed attribute immediately after the reference node.
-		/// If an attribute with the same name is already in the collection, that attribute is removed and the new attribute inserted
-		/// </summary>
-		/// <exception cref="ArgumentException">Raised if newNode OwnerDocument differs from nodelist owner or refNode is not a member of the collection</exception>
-		/// <param name="newNode">New attribute to insert</param>
-		/// <param name="refNode">Reference node to insert new node after</param>
-		/// <returns>Inserted node</returns>
-		public virtual XmlAttribute InsertAfter( XmlAttribute newNode, XmlAttribute refNode)
-		{
-			return InsertHelper(newNode, refNode, 1);
-		}
-
-		/// <summary>
-		/// Inserts newNode into the collection just before refNode.
-		/// If a node with newNode.Name is already in the list, it is removed.
-		/// </summary>
-		/// <exception cref="ArgumentException">Thrown if inserted attribute created from different document, refNode not found in collection or
-		/// refNode.Name == newNode.Name.</exception>
-		/// <param name="newNode">Node to insert into list</param>
-		/// <param name="refNode">Node to insert before</param>
-		/// <returns>Deleted node, or null if no node was deleted.</returns>
-		public virtual XmlAttribute InsertBefore(
-			XmlAttribute newNode,
-			XmlAttribute refNode
-			)
-		{
-			return InsertHelper(newNode, refNode, 0);
-		}
-
-		/// <summary>
-		/// Inserts the specified node as the first node in the collection
-		/// </summary>
-		/// <param name="node">XmlAttribute to insert</param>
-		/// <exception cref="ArgumentException">If node is null, or owner document does not match collection.</exception>
-		/// <returns>Node that was removed, or null if no node deleted.</returns>
-		public virtual XmlAttribute Prepend(XmlAttribute node)
-		{
-			//TODO - node validation? (no)
-			// TODO - set attribute owner element? (no)
-			//node.setOwnerElement(FOwnerNode as XmlElement);
-
-			if (FnodeList.Count > 0)
-			{
-				return InsertBefore(node, Item(0) as XmlAttribute);
-			}
-
-			if (node == null)
-				throw new ArgumentException("Cannot prepend null node");
-
-			if (! node.OwnerDocument.Equals(FOwner.OwnerDocument) )
-				throw new ArgumentException("Node to prepend does not have same owner document as reference");
-
-			FnodeList.Add(node);			
-			return node;
-		}
-
-		/// <summary>
-		/// Removes the requested node from the collection.
-		/// </summary>
-		/// <param name="node">Node to remove</param>
-		/// <returns>The node removed, or null if the node was not found in the collection.</returns>
-		public virtual XmlAttribute Remove(XmlAttribute node)
-		{
-			for (int i = 0; i < FnodeList.Count; i++)
-			{
-				XmlAttribute e = FnodeList[i] as XmlAttribute;
-			
-				if (e.Equals(node))
-				{
-					FnodeList.RemoveAt(i);
-					return node;
-				}
-			}
-			// TODO - if node is a default, should we add it back with a default value? (no)
-			return null;
-		}
-
-		/// <summary>
-		/// Removes all attributes from the collection
-		/// </summary>
-		public virtual void RemoveAll()
-		{
-			// Can this be this easy?
-			for (int i = FnodeList.Count - 1; i > 0; i--)
-			{
-				XmlAttribute e = FnodeList[i] as XmlAttribute;
-				e.setOwnerElement(null);
-				FnodeList.RemoveAt(i);
-			}
-
-			// TODO - Add default attributes back in in RemoveAll()?  (no)
-		}
-
-		/// <summary>
-		/// Removes the attribute at the specified index
-		/// </summary>
-		/// <param name="i">index of attribute to remove.</param>
-		/// <returns>Removed node, or null if node not in collection</returns>
-		public virtual XmlAttribute RemoveAt(int i)
-		{
-			if ((i < 0) | ( i >= FnodeList.Count))
-				return null;
-
-			// TODO - if default attribute removed in RemoveAt(), add it back? (no)
-			XmlAttribute e = FnodeList[i] as XmlAttribute;
-			FnodeList.RemoveAt(i);
-			e.setOwnerElement(null);
-			return e;
-		}
-
-		/// <summary>
-		/// Adds a node to the collection using it's name.  If a node with the same name exists,
-		/// it is removed.
-		/// </summary>
-		/// <param name="node">XmlAttribute to add.</param>
-		/// <returns>If a node replaces a named node, the replaced node is deleted and returned. 
-		/// Otherwise, null.</returns>
-		public override XmlNode SetNamedItem(XmlNode node)
-		{
-			return base.SetNamedItem(node);
-		}
-
-		public override string ToString()
-		{
-			string retval = "System.Xml.XmlAttributeCollection ";
-			if (FOwnerNode != null)
-				retval += "OwnerElement: " + FOwnerNode.Name;
-
-			foreach (XmlAttribute o in FnodeList)
-			{
-				retval += o.Name + "=" + o.Value;
-			}
-			return retval;
-
-		}
-		// ============= Constructors ========================================
-		// TODO - change constructor to pass in IEnumerator?
-		internal XmlAttributeCollection(XmlNode aOwner, XmlNode aOwnerNode, ArrayList nodeList) :
-			base(aOwner, aOwnerNode, nodeList)
-		{
-			// Makes no sense to have namespace aware on attributes
-			NamespaceAware = false;
-		}
-
-		internal XmlAttributeCollection ()
-		{
-		}
-
-	}
-}
+//
+// System.Xml.XmlAttributeCollection
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2002 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+	public class XmlAttributeCollection : XmlNamedNodeMap, ICollection
+	{
+		internal XmlAttributeCollection (XmlNode parent) : base (parent)
+		{
+		}
+
+		bool ICollection.IsSynchronized {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		[MonoTODO]
+		[System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+		public virtual XmlAttribute this [string name] {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		[MonoTODO]
+		[System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+		public virtual XmlAttribute this [int i] {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		[MonoTODO]
+		[System.Runtime.CompilerServices.IndexerName ("ItemOf")]
+		public virtual XmlAttribute this [string localName, string namespaceURI] {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		object ICollection.SyncRoot {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		[MonoTODO]
+		public virtual XmlAttribute Append (XmlAttribute node) 
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public void CopyTo (XmlAttribute [] array, int index)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		void ICollection.CopyTo (Array array, int index)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlAttribute InsertAfter (XmlAttribute newNode, XmlAttribute refNode)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlAttribute InsertBefore (XmlAttribute newNode, XmlAttribute refNode)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlAttribute Prepend (XmlAttribute node) 
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlAttribute Remove (XmlAttribute node) 
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void RemoveAll () 
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlAttribute RemoveAt (int i) 
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override XmlNode SetNamedItem (XmlNode node)
+		{
+			return base.SetNamedItem (node);
+		}
+	}
+}

+ 50 - 50
mcs/class/System.XML/System.Xml/XmlCDataSection.cs

@@ -1,50 +1,50 @@
-//
-// System.Xml.XmlCDataSection.cs
-//
-// Author: Duncan Mak ([email protected])
-//
-// (C) Ximian, Inc.
-//
-
-namespace System.Xml
-{
-	public class XmlCDataSection : XmlCharacterData
-	{
-		// Constructor
-		protected internal XmlCDataSection (string data, XmlDocument doc)
-			: base (doc)
-		{
-		}
-
-	        // Properties
-		public override string LocalName
-		{
-			get { return "#cdata-section"; }
-		}
-
-		public override string Name
-		{
-			get { return "#cdata-section"; }
-		}
-
-		public override XmlNodeType NodeType
-		{
-			get { return XmlNodeType.CDATA; }
-		}
-
-		// Methods
-		public override XmlNode CloneNode (bool deep)
-		{
-			return null;
-		}
-
-		public override void WriteContentTo (XmlWriter w)
-		{
-			// CDATA nodes have no children, WriteContentTo has no effect.
-		}
-
-		public override void WriteTo (XmlWriter w)
-		{
-		}
-	}
-}
+//
+// System.Xml.XmlCDataSection.cs
+//
+// Author: Duncan Mak ([email protected])
+//
+// (C) Ximian, Inc.
+//
+
+namespace System.Xml
+{
+	public class XmlCDataSection : XmlCharacterData
+	{
+		// Constructor
+		protected internal XmlCDataSection (string data, XmlDocument doc)
+			: base (data, doc)
+		{
+		}
+
+        // Properties
+		public override string LocalName
+		{
+			get { return "#cdata-section"; }
+		}
+
+		public override string Name
+		{
+			get { return "#cdata-section"; }
+		}
+
+		public override XmlNodeType NodeType
+		{
+			get { return XmlNodeType.CDATA; }
+		}
+
+		// Methods
+		public override XmlNode CloneNode (bool deep)
+		{
+			return null;
+		}
+
+		public override void WriteContentTo (XmlWriter w)
+		{
+			// CDATA nodes have no children, WriteContentTo has no effect.
+		}
+
+		public override void WriteTo (XmlWriter w)
+		{
+		}
+	}
+}

+ 102 - 154
mcs/class/System.XML/System.Xml/XmlCharacterData.cs

@@ -1,154 +1,102 @@
-// System.Xml.XmlCharacterData.cs
-//
-// Author: Daniel Weber ([email protected])
-//
-// Implementation of abstract Xml.XmlCharacterData class
-//
-// Provides text manipulation methods used by derived classes
-//	abstract class
-
-using System;
-
-namespace System.Xml
-{
-	/// <summary>
-	/// Abstratc class to provide text manipulation methods for derived classes
-	/// </summary>
-	public abstract class XmlCharacterData : XmlLinkedNode
-	{
-		// ============ Public Properties =====================================
-		//=====================================================================
-		/// <summary>
-		/// Contains the nodes data
-		/// </summary>
-		public virtual string Data 
-		{
-			get
-			{
-				// TODO - implement Data {get;}
-				throw new NotImplementedException();
-			}
-			
-			set
-			{
-				// TODO - implement Data {set;}
-				throw new NotImplementedException();
-			}
-		}
-
-		/// <summary>
-		/// Get/Set the nodes value
-		/// </summary>
-		public override string Value 
-		{
-			get
-			{
-				// TODO - implement Value {get;}
-				throw new NotImplementedException();
-			}
-
-			set
-			{
-				// TODO - implement Value {set;}
-				throw new NotImplementedException();
-			}
-		}
-
-		public override string InnerText 
-		{
-			get
-			{
-				// TODO - implement InnerText {get;}
-				throw new NotImplementedException();
-			}
-
-			set
-			{
-				// TODO - implement InnerText {set;}
-				throw new NotImplementedException();
-			}
-		}
-
-		/// <summary>
-		/// Returns the length of data, in characters
-		/// </summary>
-		public virtual int Length 
-		{
-			get
-			{
-				// TODO - implement Length {get;}
-				throw new NotImplementedException();
-			}
-		}
-
-		// ============ Public Methods  =======================================
-		//=====================================================================
-		/// <summary>
-		/// Appends string strData to the end of data
-		/// </summary>
-		/// <param name="strData"></param>
-		public virtual void AppendData(string strData)
-		{
-			// TODO - implement AppendData(strData)
-			throw new NotImplementedException();
-		}
-
-		/// <summary>
-		/// Remove a range of characters from the node
-		/// </summary>
-		/// <param name="offset">offset, in characters, to start delete</param>
-		/// <param name="count">Number of characters to delete</param>
-		public virtual void DeleteData(int offset, int count)
-		{
-			// TODO - implement DeleteData(offset, count)
-			throw new NotImplementedException();
-		}
-
-		/// <summary>
-		/// Replaces the number of characters, starting at offset, with the passed string
-		/// </summary>
-		/// <param name="offset">Offset (in characters) to start replacement</param>
-		/// <param name="count">Number of characters to replace</param>
-		/// <param name="strData">Replacement string</param>
-		public virtual void ReplaceData(int offset, int count, string strData)
-		{
-			// TODO - implement ReplaceData(offset, count, strData)
-			throw new NotImplementedException();
-		}
-
-		/// <summary>
-		/// Retrieves a substring of the specified range
-		/// </summary>
-		/// <param name="offset">Character offset to begin string</param>
-		/// <param name="count">Number of characters to return</param>
-		/// <returns></returns>
-		public virtual string Substring(int offset, int count)
-		{
-			// TODO - implement Substring(offset, count)
-			throw new NotImplementedException();
-		}
-
-		// ============ Protected Methods  ====================================
-		//=====================================================================
-		/// <summary>
-		/// Listed in beta 2, but no description
-		/// [to be supplied]
-		/// </summary>
-		/// <param name="node"></param>
-		/// <param name="xnt"></param>
-		/// <returns></returns>
-		protected internal bool DecideXPNodeTypeForWhitespace(
-			XmlNode node,
-			ref XPathNodeType xnt
-			)
-		{
-			// TODO
-			throw new NotImplementedException();
-		}
-
-		// Constructors
-		internal XmlCharacterData ( XmlDocument aOwnerDoc) : base(aOwnerDoc)
-		{
-		}
-	}
-}
+//
+// System.Xml.XmlText
+//
+// Author:
+//   Jason Diamond <[email protected]>
+//
+// (C) 2002 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+
+namespace System.Xml
+{
+	public abstract class XmlCharacterData : XmlLinkedNode
+	{
+		private string data;
+
+		#region Constructor
+
+		protected internal XmlCharacterData (string data, XmlDocument doc) : base (doc)
+		{
+			this.data = data;
+		}
+
+		#endregion
+		
+		#region Properties
+
+		public virtual string Data {
+			get {
+				return data;
+			}
+			
+			set {
+				data = value;
+			}
+		}
+
+		[MonoTODO]
+		public override string InnerText {
+			get {
+				throw new NotImplementedException ();
+			}
+
+			set {
+				throw new NotImplementedException ();
+			}
+		}
+
+		public int Length {
+			get {
+				return data != null ? data.Length : 0;
+			}
+		}
+
+		public override string Value {
+			get {
+				return data;
+			}
+
+			set {
+				data = value;
+			}
+		}
+
+		#endregion
+
+		#region Methods
+
+		[MonoTODO]
+		public virtual void AppendData (string strData)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void DeleteData (int offset, int count)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void InsertData (int offset, string strData)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual void ReplaceData (int offset, int count, string strData)
+		{
+			throw new NotImplementedException();
+		}
+
+		[MonoTODO]
+		public virtual string Substring(int offset, int count)
+		{
+			throw new NotImplementedException();
+		}
+
+		#endregion
+	}
+}

+ 1 - 1
mcs/class/System.XML/System.Xml/XmlComment.cs

@@ -105,7 +105,7 @@ namespace System.Xml
 
 		}
 		// Constructors
-		internal XmlComment(XmlDocument aOwner, string txt, XmlInputSource src) : base(aOwner)
+		internal XmlComment(XmlDocument aOwner, string txt, XmlInputSource src) : base(txt, aOwner)
 		{
 			XmlException e = wellFormed(txt, src);
 

+ 235 - 296
mcs/class/System.XML/System.Xml/XmlDocument.cs

@@ -1,4 +1,3 @@
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 //
 // System.Xml.XmlDocument
 //
@@ -9,22 +8,37 @@
 
 using System;
 using System.IO;
+using System.Xml.XPath;
 
 namespace System.Xml
 {
-
 	public delegate void XmlNodeChangedEventHandler (XmlNodeChangedEventArgs args);
 
-	/// <summary>
-	/// Abstract class XmlNodeList.
-	/// </summary>
 	public class XmlDocument : XmlNode
 	{
-		// Private data members
-		XmlResolver _resolver = null;
+		#region Constructors
+
+		public XmlDocument () : base (null)
+		{
+			FOwnerDocument = this;
+		}
+
+		[MonoTODO]
+		protected internal XmlDocument (XmlImplementation imp) : base (null)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public XmlDocument (NameTable nt) : base (null)
+		{
+			throw new NotImplementedException ();
+		}
+
+		#endregion
+
+		#region Events
 
-		// Public events
-		//===========================================================================
 		public event XmlNodeChangedEventHandler NodeChanged;
 
 		public event XmlNodeChangedEventHandler NodeChanging;
@@ -37,29 +51,19 @@ namespace System.Xml
 
 		public event XmlNodeChangedEventHandler NodeRemoving;
 
-		// public properties
+		#endregion
 
-		/// <summary>
-		/// Get the base URI for this document (the location from where the document was loaded)
-		/// </summary>
-		/// <example>If a document was loaded with doc.Load("c:\tmp\mydoc.xml"),
-		/// then BaseURI would hold "c:\tmp\mydoc.xml"</example>
-		public override string BaseURI
-		{
-			get
-			{
-				// TODO - implement XmlDocument.BaseURI {get;}
-				throw new NotImplementedException("BaseURI.get not implemented");
+		#region Properties
+
+		[MonoTODO]
+		public override string BaseURI {
+			get {
+				throw new NotImplementedException();
 			}
 		}
 
-		/// <summary>
-		/// Get the root element for the document.  If no root exists, null is returned.
-		/// </summary>
-		public XmlElement DocumentElement
-		{
-			get
-			{
+		public XmlElement DocumentElement {
+			get {
 				XmlNode node = FirstChild;
 
 				while (node != null) {
@@ -72,429 +76,372 @@ namespace System.Xml
 			}
 		}
 
-		/// <summary>
-		/// Gets the node containing the DOCTYPE declaration.
-		/// </summary>
-		public virtual XmlDocumentType DocumentType
-		{
-			get
-			{
-				// TODO - implement XmlDocument.DocumentType
-				throw new NotImplementedException("XmlDocument.DocumentType not implemented");
+		[MonoTODO]
+		public virtual XmlDocumentType DocumentType {
+			get {
+				throw new NotImplementedException();
 			}
 		}
 
-
-		/// <summary>
-		/// Get the XmlImplemenation for the current document.
-		/// </summary>
-		public XmlImplementation Implementation
-		{
-			get
-			{
-				// TODO - implement XmlDocument.Implementation
-				throw new NotImplementedException("Implementation not implemented");
+		[MonoTODO]
+		public XmlImplementation Implementation {
+			get {
+				throw new NotImplementedException();
 			}
 		}
 
-
-		/// <summary>
-		/// Get/Set the markup representing the children of the document.
-		/// </summary>
-		public override string InnerXml
-		{
-			get
-			{
-				// TODO - implement XmlDocument.InnerXml {get;}
-				throw new NotImplementedException("InnerXml get not implemented");
+		[MonoTODO]
+		public override string InnerXml {
+			get {
+				throw new NotImplementedException();
 			}
-			set
-			{
-				// TODO - implement XmlDocument.InnerXml {set;}
-				throw new NotImplementedException("InnerXml set not implemented");
+
+			set {
+				throw new NotImplementedException();
 			}
 		}
 
-		/// <summary>
-		/// Get a value indicating if the document is read-only.
-		/// </summary>
-		public override bool IsReadOnly
-		{
-			get
-			{
-				return false;
+		public override bool IsReadOnly {
+			get { 
+				return false; 
 			}
 		}
 
-		/// <summary>
-		/// Get the local name of the node.  For documents, returns "#document"
-		/// </summary>
 		public override string LocalName {
-			get
-			{
-				return "#document";
+			get { 
+				return "#document"; 
 			}
 		}
 
-		/// <summary>
-		/// Get the qualified name of the node.  For documents, returns "#document"
-		/// </summary>
-		public override string Name
-		{
-			get
-			{
-				return "#document";
+		public override string Name {
+			get { 
+				return "#document"; 
 			}
 		}
 
-		public XmlNameTable NameTable
-		{
-			get
-			{
-				// TODO - implement XmlDocument.NameTable {get;}
-				throw new NotImplementedException("NameTable get not implemented");
+		[MonoTODO]
+		public XmlNameTable NameTable {
+			get {
+				throw new NotImplementedException();
 			}
 		}
 
-
-		public override XmlNodeType NodeType
-		{
-			get
-			{
-				return XmlNodeType.Document;
+		public override XmlNodeType NodeType {
+			get { 
+				return XmlNodeType.Document; 
 			}
 		}
 
-		/// <summary>
-		/// Returns OwnerDocument.  For an XmlDocument, this property is always null.
-		/// </summary>
-		public override XmlDocument OwnerDocument
-		{
-			get
-			{
-				return null;
+		public override XmlDocument OwnerDocument {
+			get { 
+				return null; 
 			}
 		}
 
-		public bool PreserveWhitespace
-		{
-			get
-			{
-				// TODO - implement XmlDocument.PreserveWhitespace {get;}
-				throw new NotImplementedException("PreserveWhitespace get not implemented");
+		[MonoTODO]
+		public bool PreserveWhitespace {
+			get {
+				throw new NotImplementedException();
 			}
-			set
-			{
-				// TODO - implement XmlDocument.PreserveWhitespace {set;}
-				throw new NotImplementedException("PreserveWhitespace set not implemented");
+
+			set {
+				throw new NotImplementedException();
 			}
 		}
 
-		public XmlResolver XmlResolver
-		{
-			set
-			{
-				// TODO - Finish/test XmlDocument.XmlResolver {set;}
-				_resolver = value;
+		[MonoTODO]
+		public XmlResolver XmlResolver {
+			set {
+				throw new NotImplementedException();
 			}
 		}
 
-		// Public Methods
-		//===========================================================================
-		public override XmlNode CloneNode(bool deep)
+		#endregion
+
+		#region Methods
+
+		[MonoTODO]
+		public override XmlNode CloneNode (bool deep)
 		{
-			// TODO - implement XmlDocument.CloneNode(bool)
-			throw new NotImplementedException("CloneNode(bool) not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public XmlAttribute CreateAttribute(string name)
+		[MonoTODO]
+		public XmlAttribute CreateAttribute (string name)
 		{
-			return new XmlAttribute(this, name, "");
+			return new XmlAttribute (this, name, "");
 		}
 
-		public XmlAttribute CreateAttribute(string qualifiedName,string namespaceURI)
+		[MonoTODO]
+		public XmlAttribute CreateAttribute (string qualifiedName, string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateAttribute(string, string)
-			throw new NotImplementedException("CreateAttribute(string, string) not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlAttribute CreateAttribute(
-			string prefix,
-			string localName,
-			string namespaceURI
-			)
+		[MonoTODO]
+		public virtual XmlAttribute CreateAttribute (string prefix, string localName, string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateAttribute(prefix, localName, namespaceURI)
-			throw new NotImplementedException("CreateAttribute(prefix, localName, namespaceURI) not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlCDataSection CreateCDataSection(string data)
+		[MonoTODO]
+		public virtual XmlCDataSection CreateCDataSection (string data)
 		{
-			// TODO - implement XmlDocument.CreateCDataSection(string data)
-			throw new NotImplementedException("CreateCDataSection(string data) not implemented");
+			throw new NotImplementedException ();
 		}
 
+		[MonoTODO]
+		public virtual XmlComment CreateComment (string data)
+		{
+			throw new NotImplementedException ();
+		}
 
-		public virtual XmlComment CreateComment(string data)
+		[MonoTODO]
+		protected internal virtual XmlAttribute CreateDefaultAttribute (string prefix, string localName, string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateComment(string data)
-			throw new NotImplementedException("CreateComment(string data) not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlDocumentFragment CreateDocumentFragment()
+		[MonoTODO]
+		public virtual XmlDocumentFragment CreateDocumentFragment ()
 		{
-			// TODO - implement XmlDocument.CreateDocumentFragment
-			throw new NotImplementedException("CreateDocumentFragment not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlDocumentType CreateDocumentType(
+		[MonoTODO]
+		public virtual XmlDocumentType CreateDocumentType (
 			string name,
 			string publicId,
 			string systemId,
-			string internalSubset
-			)
+			string internalSubset)
 		{
-			// TODO - implement XmlDocument.CreateDocumentType
-			throw new NotImplementedException("CreateDocumentType not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public XmlElement CreateElement(string name)
+		[MonoTODO]
+		public XmlElement CreateElement (string name)
 		{
-			// TODO - implement XmlDocument.CreateElement(string name)
-			throw new NotImplementedException("CreateElement(string name) not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public XmlElement CreateElement(
-			string qualifiedName,
-			string namespaceURI
-			)
+		[MonoTODO]
+		public XmlElement CreateElement (string qualifiedName, string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateElement(string qualifiedName,	string namespaceURI)
-			throw new NotImplementedException("CreateElement(string qualifiedName,	string namespaceURI) not implemented");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlElement CreateElement(
+		public virtual XmlElement CreateElement (
 			string prefix,
 			string localName,
-			string namespaceURI
-			)
+			string namespaceURI)
 		{
-			return new XmlElement(prefix, localName, namespaceURI, this);
+			return new XmlElement (prefix, localName, namespaceURI, this);
 		}
 
+		[MonoTODO]
+		public virtual XmlEntityReference CreateEntityReference (string name)
+		{
+			throw new NotImplementedException ();
+		}
 
-		public virtual XmlEntityReference CreateEntityReference(string name)
+		[MonoTODO]
+		protected internal virtual XPathNavigator CreateNavigator (XmlNode node)
 		{
-			// TODO - implement XmlDocument.CreateEntityReference
-			throw new NotImplementedException("XmlDocument.CreateEntityReference not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlNode CreateNode(
+		[MonoTODO]
+		public virtual XmlNode CreateNode (
 			string nodeTypeString,
 			string name,
-			string namespaceURI
-			)
+			string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateNode(string, string, string)
-			throw new NotImplementedException("XmlDocument.CreateNode not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlNode CreateNode(
+		[MonoTODO]
+		public virtual XmlNode CreateNode (
 			XmlNodeType type,
 			string name,
-			string namespaceURI
-			)
+			string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateNode(XmlNodeType, string, string)
-			throw new NotImplementedException("XmlDocument.CreateNode not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlNode CreateNode(
+		[MonoTODO]
+		public virtual XmlNode CreateNode (
 			XmlNodeType type,
 			string prefix,
 			string name,
-			string namespaceURI
-			)
+			string namespaceURI)
 		{
-			// TODO - implement XmlDocument.CreateNode(XmlNodeType, string, string, string)
-			throw new NotImplementedException("XmlDocument.CreateNode not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlProcessingInstruction CreateProcessingInstruction(
+		[MonoTODO]
+		public virtual XmlProcessingInstruction CreateProcessingInstruction (
 			string target,
-			string data
-			)
+			string data)
 		{
-			// TODO - implement XmlDocument.CreateProcessingInstruction
-			throw new NotImplementedException("XmlDocument.CreateProcessingInstruction not implemented.");
+			throw new NotImplementedException();
 		}
 
-		public virtual XmlSignificantWhitespace CreateSignificantWhitespace(string text	)
+		[MonoTODO]
+		public virtual XmlSignificantWhitespace CreateSignificantWhitespace (string text	)
 		{
-			// TODO - implement XmlDocument.CreateSignificantWhitespace
-			throw new NotImplementedException("XmlDocument.CreateSignificantWhitespace not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlText CreateTextNode(string text)
+		public virtual XmlText CreateTextNode (string text)
 		{
-			// TODO - implement XmlDocument.CreateTextNode
-			throw new NotImplementedException("XmlDocument.CreateTextNode not implemented.");
+			return new XmlText (text, this);
 		}
 
-		public virtual XmlWhitespace CreateWhitespace(string text)
+		[MonoTODO]
+		public virtual XmlWhitespace CreateWhitespace (string text)
 		{
-			// TODO - implement XmlDocument.CreateWhitespace
-			throw new NotImplementedException("XmlDocument.CreateWhitespace not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlDeclaration CreateXmlDeclaration(
+		[MonoTODO]
+		public virtual XmlDeclaration CreateXmlDeclaration (
 			string version,
 			string encoding,
-			string standalone
-			)
-		{
-			// TODO - implement XmlDocument.CreateXmlDeclaration
-			throw new NotImplementedException("XmlDocument.CreateXmlDeclaration not implemented.");
-		}
-
-		public virtual XmlElement GetElementById(string elementId)
+			string standalone)
 		{
-			// TODO - implement XmlDocument.GetElementById
-			throw new NotImplementedException("XmlDocument.GetElementById not implemented.");
+			throw new NotImplementedException();
 		}
 
-		public virtual XmlNodeList GetElementsByTagName(string name)
+		[MonoTODO]
+		public virtual XmlElement GetElementById (string elementId)
 		{
-			// TODO - implement XmlDocument.GetElementsByTagName(name)
-			throw new NotImplementedException("XmlDocument.GetElementsByTagName not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlNodeList GetElementsByTagName(
-			string localName,
-			string namespaceURI
-			)
+		[MonoTODO]
+		public virtual XmlNodeList GetElementsByTagName (string name)
 		{
-			// TODO - implement XmlDocument.GetElementsByTagName(localName, namespaceURI)
-			throw new NotImplementedException("XmlDocument.GetElementsByTagName not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual XmlNode ImportNode(
-			XmlNode node,
-			bool deep
-			)
+		[MonoTODO]
+		public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
 		{
-			// TODO - implement XmlDocument.ImportNode
-			throw new NotImplementedException("XmlDocument.ImportNode not implemented.");
+			throw new NotImplementedException();
 		}
 
-		public virtual void Load(Stream inStream)
+		[MonoTODO]
+		public virtual XmlNode ImportNode (XmlNode node, bool deep)
 		{
-			// TODO - implement XmlDocument.Load(Stream)
-			throw new NotImplementedException("XmlDocument.Load(Stream) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual void Load(string filename)
+		[MonoTODO]
+		public virtual void Load (Stream inStream)
 		{
-			// TODO - implement XmlDocument.Load(string)
-			throw new NotImplementedException("XmlDocument.Load(string) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual void Load(TextReader txtReader)
+		public virtual void Load (string filename)
 		{
-			// TODO - implement XmlDocument.Load(TextReader)
-			throw new NotImplementedException("XmlDocument.Load(TextReader) not implemented.");
+			XmlReader xmlReader = new XmlTextReader (new StreamReader (filename));
+			Load (xmlReader);
 		}
 
-		public virtual void Load(XmlReader reader)
+		[MonoTODO]
+		public virtual void Load (TextReader txtReader)
 		{
-			// TODO - implement XmlDocument.Load(XmlReader)
-			throw new NotImplementedException("XmlDocument.Load(XmlReader) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual void LoadXml(string xml)
+		public virtual void Load (XmlReader xmlReader)
 		{
-			XmlReader	xmlReader = new XmlTextReader(new StringReader(xml));
-			XmlNode		currentNode = this;
-			XmlNode		newNode;
-
 			// Reset our document
 			// For now this just means removing all our children but later this
 			// may turn out o need to call a private method that resets other things
 			// like properties we have, etc.
-			RemoveAll();
+			RemoveAll ();
 
-			// Wrapping in try/catch for now until XmlTextReader starts throwing XmlException
-			try 
+			XmlNode currentNode = this;
+
+			while (xmlReader.Read ()) 
 			{
-				while (xmlReader.Read())
-				{
-					switch(xmlReader.NodeType)
-					{
-						case XmlNodeType.Element:
-							newNode = CreateElement(xmlReader.Name, xmlReader.LocalName, xmlReader.NamespaceURI);
-							currentNode.AppendChild(newNode);
-							if (!xmlReader.IsEmptyElement)
-							{
-								currentNode = newNode;
-							}
-							break;
-						
-						case XmlNodeType.Text:
-							newNode = CreateTextNode(xmlReader.Value);
-							currentNode.AppendChild(newNode);
-							break;
-
-						case XmlNodeType.EndElement:
-							currentNode = currentNode.ParentNode;
-							break;
-					}
+				switch (xmlReader.NodeType) {
+
+				case XmlNodeType.Element:
+					XmlElement element = CreateElement (xmlReader.Name, xmlReader.LocalName, xmlReader.NamespaceURI);
+					currentNode.AppendChild (element);
+
+					// set the element's attributes.
+					while (xmlReader.MoveToNextAttribute ())
+						element.SetAttribute (xmlReader.Name, xmlReader.Value);
+
+					// if this element isn't empty, push it onto our "stack".
+					if (!xmlReader.IsEmptyElement)
+						currentNode = element;
+
+					break;
+
+				case XmlNodeType.Text:
+					XmlText text = CreateTextNode (xmlReader.Value);
+					currentNode.AppendChild (text);
+					break;
+
+				case XmlNodeType.EndElement:
+					currentNode = currentNode.ParentNode;
+					break;
 				}
 			}
-			catch(Exception e)
-			{
-				throw new XmlException(e.Message, e);
-			}
 		}
 
-		public virtual void Save(Stream outStream)
+		public virtual void LoadXml (string xml)
+		{
+			XmlReader xmlReader = new XmlTextReader (new StringReader (xml));
+			Load (xmlReader);
+		}
+
+		[MonoTODO]
+		public virtual XmlNode ReadNode(XmlReader reader)
 		{
-			// TODO - implement XmlDocument.Save(Stream)
-			throw new NotImplementedException("XmlDocument.Save(Stream) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual void Save(string filename)
+		[MonoTODO]
+		public virtual void Save(Stream outStream)
 		{
-			// TODO - implement XmlDocument.Save(string)
-			throw new NotImplementedException("XmlDocument.Save(string) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual void Save(TextWriter writer)
+		[MonoTODO]
+		public virtual void Save (string filename)
 		{
-			// TODO - implement XmlDocument.Save(TextWriter)
-			throw new NotImplementedException("XmlDocument.Save(TextWriter) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public virtual void Save(XmlWriter writer)
+		[MonoTODO]
+		public virtual void Save (TextWriter writer)
 		{
-			// TODO - implement XmlDocument.Save(XmlWriter)
-			throw new NotImplementedException("XmlDocument.Save(XmlWriter) not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public override void WriteContentTo(XmlWriter w)
+		[MonoTODO]
+		public virtual void Save (XmlWriter writer)
 		{
-			// TODO - implement XmlDocument.WriteContentTo
-			throw new NotImplementedException("XmlDocument.WriteContentTo not implemented.");
+			throw new NotImplementedException ();
 		}
 
-		public override void WriteTo(XmlWriter w)
+		[MonoTODO]
+		public override void WriteContentTo (XmlWriter xw)
 		{
-			// TODO - implement XmlDocument.WriteTo
-			throw new NotImplementedException("XmlDocument.WriteTo not implemented.");
+			throw new NotImplementedException ();
 		}
 
+		[MonoTODO]
+		public override void WriteTo (XmlWriter w)
+		{
+			throw new NotImplementedException ();
+		}
 
-		// Internal functions
-		//===========================================================================
 		internal void onNodeChanging(XmlNode node, XmlNode Parent)
 		{
 			if (NodeInserting != null)
@@ -535,16 +482,8 @@ namespace System.Xml
 			if (NodeRemoved != null)
 				NodeRemoved(new XmlNodeChangedEventArgs(XmlNodeChangedAction.Remove,
 					node, oldParent, null));
-
 		}
 
-		// Constructors
-		//===========================================================================
-		public XmlDocument() : base(null)
-		{
-			FOwnerDocument = this;
-		}
-
-
+		#endregion
 	}
 }

+ 7 - 4
mcs/class/System.XML/System.Xml/XmlElement.cs

@@ -29,7 +29,7 @@ namespace System.Xml
 			this.localName = localName;
 			this.namespaceURI = namespaceURI;
 
-			attributes = new XmlAttributeCollection(doc, this, null);
+			attributes = new XmlAttributeCollection(this);
 		}
 
 		#endregion
@@ -125,9 +125,10 @@ namespace System.Xml
 		}
 
 		[MonoTODO]
-		public virtual string GetAttribute(string name)
+		public virtual string GetAttribute (string name)
 		{
-			throw new NotImplementedException();
+			XmlNode attributeNode = Attributes.GetNamedItem (name);
+			return attributeNode != null ? attributeNode.Value : String.Empty;
 		}
 
 		[MonoTODO]
@@ -221,7 +222,9 @@ namespace System.Xml
 		[MonoTODO]
 		public virtual void SetAttribute(string name, string value)
 		{
-			throw new NotImplementedException();
+			XmlAttribute attribute = OwnerDocument.CreateAttribute (name);
+			attribute.Value = value;
+			Attributes.SetNamedItem (attribute);
 		}
 
 		[MonoTODO]

+ 81 - 279
mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs

@@ -1,279 +1,81 @@
-//
-// System.Xml.XmlNamedNodeMap.cs
-//
-// Author: Daniel Weber ([email protected])
-//
-// Implementation of abstract System.Xml.XmlNamedNodeMap class
-//
-// Credit for source code to Open XML 2.3.17
-
-using System;
-using System.Collections;
-
-namespace System.Xml
-{
-
-	public class XmlNamedNodeMap : IEnumerable
-	{
-		//=============== Class data structures ====================================
-		// Use weak references for owners to prevent circular linkage
-		protected XmlNode FOwner;
-		protected XmlNode FOwnerNode;
-
-		protected ArrayList FnodeList;
-		private bool FNamespaceAware;
-		private bool FIsReadonly;
-
-		// ============ Public Properties =====================================
-		//=====================================================================
-		/// <summary>
-		/// Get the count of nodes in the map
-		/// </summary>
-		public virtual int Count 
-		{
-			get
-			{
-				return FnodeList.Count;
-			}
-		}
-		
-		// ============ Public Methods    =====================================
-		/// <summary>
-		/// Get the node at the given index.  Index is 0-based, top element is Count - 1
-		/// </summary>
-		/// <param name="index">index into array of XmlNode to get</param>
-		/// <returns>XmlNode at index, or null if index out of range</returns>
-		public virtual XmlNode Item(int index)
-		{
-			try
-			{
-				return FnodeList[index] as XmlNode;   //FnodeList.Item(index);
-			}
-			catch (ArgumentOutOfRangeException)
-			{
-				return null;
-			}
-		}
-
-		/// <summary>
-		/// Get the node with the given name
-		/// If the nodes have an associated namespace, use (localName, namespaceURI) instead
-		/// </summary>
-		/// <param name="name">name of the node to return</param>
-		/// <returns>XmlNode, or null if node not found</returns>
-		public virtual XmlNode GetNamedItem(string name)
-		{
-			// Can't return without a namespace to lookup
-			// SDK doesn't specify an exception to throw, so just return null
-			if (FNamespaceAware) 
-				return null;
-
-			foreach (XmlNode cur in FnodeList)
-			{
-				if (cur.Name == name)
-					return cur;
-			}
-
-			return null;
-
-		}
-		
-		/// <summary>
-		/// Get the node with localName in given namespaceURI
-		/// </summary>
-		/// <param name="localName">localName of node</param>
-		/// <param name="namespaceURI">namespace of node</param>
-		/// <returns>XmlNode at location, or null</returns>
-		public virtual XmlNode GetNamedItem(string localName, string namespaceURI)
-		{
-			// No namespace data in objects, can't lookup
-			// SDK doesn't specify an exception to throw, so just return null
-			if (! FNamespaceAware)
-				return null;
-
-			foreach (XmlNode cur in FnodeList)
-			{
-				if ((cur.Name == localName) & (cur.NamespaceURI == namespaceURI))
-					return cur;
-			}
-			return null;
-
-		}
-
-		/// <summary>
-		/// Get the enumerator for the node map
-		/// </summary>
-		/// <returns>Enumerator</returns>
-		public virtual IEnumerator GetEnumerator()
-		{
-			return FnodeList.GetEnumerator();
-		}
-
-		
-		/// <summary>
-		/// Removes the node with given name from the Map and returns it.
-		/// If the node is namespace aware, use RemoveNamedItem(localName, namespaceURI) instead
-		/// </summary>
-		/// <param name="name">node name</param>
-		/// <returns>Removed node, or null if node not found</returns>
-		public virtual XmlNode RemoveNamedItem(string name)
-		{
-			// Can't return without a namespace to lookup
-			// SDK doesn't specify an exception to throw, so just return null
-			if (FNamespaceAware) 
-				return null;
-
-			for (int i = 0; i < FnodeList.Count; i++)
-			{
-				XmlNode cur = FnodeList[i] as XmlNode;
-				if (cur.Name == name)
-				{
-					FnodeList.RemoveAt(i);
-					return cur;
-				}
-			}
-			return null;
-		}
-
-		/// <summary>
-		/// Removes the node with given localName in namespaceURI
-		/// If this XmlNamedNodeMap is not namespace aware, use RemoveNamedItem(name) instead.
-		/// </summary>
-		/// <param name="localName">local node name</param>
-		/// <param name="namespaceURI">namespace node is in</param>
-		/// <returns>Node that was removed, or null if no node found</returns>
-		public virtual XmlNode RemoveNamedItem(string localName, string namespaceURI)
-		{
-			// No namespace data in objects, can't lookup
-			// SDK doesn't specify an exception to throw, so just return null
-			if (! FNamespaceAware)  // NOT _namespaceAware
-				return null;
-
-			for (int i = 0; i < FnodeList.Count; i++)
-			{
-				XmlNode cur = FnodeList[i] as XmlNode;
-				if ((cur.Name == localName) & (cur.NamespaceURI == namespaceURI))
-				{
-					FnodeList.RemoveAt(i);
-					return cur;
-				}
-			}
-			return null;
-		}
-
-		/// <summary>
-		/// Adds the passed node using the name property
-		/// If a node with this name exists, it is returned, otherwise null is returned.
-		/// </summary>
-		/// <exception cref="ArgumentException">Raised if node was created from another docuement, or XmlNamedNodeMap is read-only</exception>
-		/// <exception cref="InvalidOperationException">Node is an XmlAttribute of another XmlElement</exception>
-		/// <param name="node"></param>
-		/// <returns></returns>
-		public virtual XmlNode SetNamedItem(XmlNode node)
-		{
-			XmlNode retValue ;		// Return value of method
-
-			// Can't add to read-only Map
-			if (FIsReadonly)
-				throw new ArgumentException("Attempt to add node to read-only Node Map");
-			
-			//if FOwner.OwnerDocument <> arg.OwnerDocument then raise EWrong_Document_Err
-			if (! FOwner.OwnerDocument.Equals(node.OwnerDocument))
-				throw new ArgumentException("Cannot add node from another document");
-		
-			// if FNamespaceAware then raise ENamespace_Err.create('Namespace error.');
-			if (FNamespaceAware)
-				throw new InvalidOperationException("Invalid Operation: Can't add node by name to namespace aware node list");
-
-			// Can't assign node that has a parent
-			// TODO - is this check required/valid in the .NET API?
-			//if assigned(arg.parentNode) then raise EInuse_Node_Err.create('In use node error.');
-			if (node.ParentNode != null)
-				throw new ArgumentException("In use node error");
-
-			// XmlAttribute cannot be assigned to an element
-			//if arg.NodeType = ntAttribute_Node
-			//	then if assigned((arg as TdomAttr).OwnerElement)
-			//			 then if (arg as TdomAttr).OwnerElement <> FOwnerNode then raise EInuse_Attribute_Err.create('Inuse attribute error.');
-
-			if (node is XmlAttribute)
-			{
-				if ((node as XmlAttribute).OwnerElement != null)
-				{
-					if (! FOwnerNode.Equals( (node as XmlAttribute).OwnerElement ))
-						throw new InvalidOperationException("XmlAttribute is assigned to another element");
-				}
-			}
-
-			/* 
-			if not (arg.NodeType in FAllowedNodeTypes) then raise EHierarchy_Request_Err.create('Hierarchy request error.');
-			*/
-
-			if ( GetNamedItem(node.Name) != null)
-			{ 
-				retValue = RemoveNamedItem(node.Name); 
-			}
-			else
-			{ 
-				retValue = null;
-			}
-
-			FnodeList.Add(node);
-
-			// TODO - check that owner is set properly on adding an attribute node
-
-			return retValue;
-		}
-
-		// ============ Constructors  =========================================
-		internal XmlNamedNodeMap(XmlNode aOwner, XmlNode aOwnerNode, ArrayList nodeList)
-		{
-			if (nodeList == null)
-				nodeList = new ArrayList();
-			else
-				FnodeList = nodeList;
-			FOwner = aOwner;
-			FOwnerNode = aOwnerNode;
-			FIsReadonly = false;
-			FNamespaceAware = false;
-		}
-
-		// Add a default costructor to satisfy Visual Studio....
-		// TODO - figure out a way to get rid of default constructor on XmlNamedNodeMap()
-		internal XmlNamedNodeMap()
-		{
-			FnodeList = new ArrayList();
-			FOwner = null;
-			FOwnerNode = null;
-			FIsReadonly = false;
-			FNamespaceAware = false;
-		}
-
-		// ============ Internal Properties ===================================
-		//=====================================================================
-		internal bool IsReadOnly
-		{
-			get 
-			{ 
-				return FIsReadonly;
-			}
-			set 
-			{ 
-				FIsReadonly = value;
-			}
-		}
-
-		internal bool NamespaceAware
-		{
-			get 
-			{ 
-				return FNamespaceAware; 
-			}
-			set 
-			{ 
-				FNamespaceAware = value;
-			}
-		}
-
-	}
-}
+//
+// System.Xml.XmlNamedNodeMap
+//
+// Author:
+//   Jason Diamond ([email protected])
+//
+// (C) 2002 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+using System.Collections;
+
+namespace System.Xml
+{
+	public class XmlNamedNodeMap : IEnumerable
+	{
+		private XmlNode parent;
+		private ArrayList nodeList;
+
+		internal XmlNamedNodeMap (XmlNode parent)
+		{
+			this.parent = parent;
+			nodeList = new ArrayList ();
+		}
+
+		[MonoTODO]
+		public virtual int Count {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+
+		[MonoTODO]
+		public virtual IEnumerator GetEnumerator () 
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlNode GetNamedItem (string name)
+		{
+			foreach (XmlNode node in nodeList) {
+				if (node.Name == name)
+					return node;
+			}
+
+			return null;
+		}
+
+		[MonoTODO]
+		public virtual XmlNode GetNamedItem (string localName, string namespaceURI)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlNode Item (int index)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlNode RemoveNamedItem (string name)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlNode RemoveNamedItem (string localName, string namespaceURI)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlNode SetNamedItem (XmlNode node)
+		{
+			nodeList.Add (node);
+			return node;
+		}
+	}
+}

+ 69 - 88
mcs/class/System.XML/System.Xml/XmlText.cs

@@ -1,88 +1,69 @@
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
-//
-// System.Xml.XmlText
-//
-// Author:
-//   Daniel Weber ([email protected])
-//
-// (C) 2001 Daniel Weber
-
-
-using System;
-
-namespace System.Xml
-{
-	/// <summary>
-	/// Represents the text content of an element or attribute
-	/// </summary>
-	public class XmlText : XmlNode
-	{
-		// Private data members
-
-		// public properties
-		public override string LocalName 
-		{
-			get
-			{
-				return "#text";
-			}
-		}
-		/// <summary>
-		/// Get the name of the node.
-		/// </summary>
-		public override string Name 
-		{
-			get
-			{
-				return "#text";
-			}
-		}
-
-		public override XmlNodeType NodeType
-		{
-			get
-			{
-				return XmlNodeType.Text;
-			}
-		}
-		
-
-		// Public Methods
-		//===========================================================================
-		/// <summary>
-		/// Override.  Throw InvalidOperationException - text nodes do not have child nodes
-		/// </summary>
-		/// <param name="newChild">N/A</param>
-		/// <param name="refChild">N/A</param>
-		/// <returns>N/A</returns>
-		public override XmlNode InsertAfter(XmlNode newChild, XmlNode refChild)
-		{
-			throw new InvalidOperationException("#text nodes do not have child nodes");
-		}
-
-		public override XmlNode CloneNode( bool deep)
-		{
-			throw new NotImplementedException();
-		}
-
-		public override void WriteContentTo(XmlWriter w)
-		{
-			throw new NotImplementedException();
-		}
-
-		public override void WriteTo(XmlWriter w)
-		{
-			throw new NotImplementedException();
-		}
-
-		// Internal method calls
-		//===========================================================================
-
-		// Constructors
-		//===========================================================================
-		internal XmlText (XmlDocument aOwnerDoc ) : base(aOwnerDoc)
-		{
-		}
-
-	}
-}
+//
+// System.Xml.XmlText
+//
+// Author:
+//   Jason Diamond <[email protected]>
+//
+// (C) 2002 Jason Diamond  http://injektilo.org/
+//
+
+using System;
+
+namespace System.Xml
+{
+	public class XmlText : XmlCharacterData
+	{
+		#region Constructor
+
+		protected internal XmlText (string strData, XmlDocument doc) : base(strData, doc)
+		{
+		}
+
+		#endregion
+
+		#region Properties
+
+		public override string LocalName 
+		{
+			get { return "#text"; }
+		}
+
+		public override string Name {
+			get { return "#text"; }
+		}
+
+		public override XmlNodeType NodeType {
+			get { return XmlNodeType.Text; }
+		}
+
+		#endregion
+
+		#region Methods
+
+		[MonoTODO]
+		public override XmlNode CloneNode (bool deep)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual XmlText SplitText (int offset)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override void WriteContentTo (XmlWriter w)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override void WriteTo (XmlWriter w)
+		{
+			throw new NotImplementedException ();
+		}
+
+		#endregion
+	}
+}

+ 24 - 2
mcs/class/System.XML/System.Xml/XmlTextReader.cs

@@ -384,10 +384,28 @@ namespace System.Xml
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
 		public override bool MoveToNextAttribute ()
 		{
-			throw new NotImplementedException ();
+			if (attributes == null)
+				return false;
+
+			if (attributeEnumerator == null)
+				attributeEnumerator = attributes.GetEnumerator();
+
+			if (attributeEnumerator.MoveNext ()) {
+				string name = attributeEnumerator.Key as string;
+				string value = attributeEnumerator.Value as string;
+				SetProperties (
+					XmlNodeType.Attribute, // nodeType
+					name, // name
+					false, // isEmptyElement
+					value, // value
+					false // clearAttributes
+				);
+				return true;
+			}
+
+			return false;
 		}
 
 		public override bool Read ()
@@ -477,6 +495,7 @@ namespace System.Xml
 		private bool isEmptyElement;
 		private string value;
 		private Hashtable attributes;
+		private IDictionaryEnumerator attributeEnumerator;
 
 		private bool returnEntityReference;
 		private string entityReferenceName;
@@ -511,6 +530,7 @@ namespace System.Xml
 			isEmptyElement = false;
 			value = String.Empty;
 			attributes = new Hashtable ();
+			attributeEnumerator = null;
 			
 			returnEntityReference = false;
 			entityReferenceName = String.Empty;
@@ -566,6 +586,8 @@ namespace System.Xml
 		{
 			if (attributes.Count > 0)
 				attributes.Clear ();
+
+			attributeEnumerator = null;
 		}
 
 		private int PeekChar ()

+ 7 - 0
mcs/class/System.XML/Test/ChangeLog

@@ -1,3 +1,10 @@
+2002-03-02  Jason Diamond <[email protected]>
+
+	* XmlTextReaderTests.cs: Test MoveToNextAttribute().
+
+	* XmlDocumentTests.cs: Test loading document containing attributes
+	and text nodes.
+
 2002-03-02  Mike Kestner <[email protected]>
 
 	* XmlAttributeTests.cs : New test suite for attrs.

+ 5 - 0
mcs/class/System.XML/Test/Microsoft.Test.csproj

@@ -86,6 +86,11 @@
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
+                <File
+                    RelPath = "XmlAttributeTests.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
                 <File
                     RelPath = "XmlDocumentTests.cs"
                     SubType = "Code"

+ 5 - 0
mcs/class/System.XML/Test/Mono.Test.csproj

@@ -86,6 +86,11 @@
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
+                <File
+                    RelPath = "XmlAttributeTests.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
                 <File
                     RelPath = "XmlDocumentTests.cs"
                     SubType = "Code"

+ 1 - 1
mcs/class/System.XML/Test/XmlAttributeTests.cs

@@ -28,7 +28,7 @@ namespace Ximian.Mono.Tests
 
 		public void TestAttributes()
 		{
-			AssertNotNull(attr.Attributes);
+			AssertNull(attr.Attributes);
 		}
 
 		public void TestHasChildNodes()

+ 51 - 43
mcs/class/System.XML/Test/XmlDocumentTests.cs

@@ -1,79 +1,87 @@
 using System;
-using System.Diagnostics;
 using System.Xml;
+
 using NUnit.Framework;
 
 namespace Ximian.Mono.Tests
 {
 	public class XmlDocumentTests : TestCase
 	{
-		public XmlDocumentTests() : base("Ximian.Mono.Tests.XmlDocumentTests testsuite") { }
-		public XmlDocumentTests(string name) : base(name) { }
+		public XmlDocumentTests () : base ("Ximian.Mono.Tests.XmlDocumentTests testsuite") {}
+		public XmlDocumentTests (string name) : base (name) {}
 
 		private XmlDocument document;
 
-		protected override void SetUp()
+		protected override void SetUp ()
 		{
-			document = new XmlDocument();
+			document = new XmlDocument ();
 		}
 		
-		public void TestLoadXmlSingleElement()
+		public void TestLoadXmlSingleElement ()
 		{
-			AssertNull(document.DocumentElement);
-			document.LoadXml("<foo/>");
-			AssertNotNull(document.DocumentElement);
+			AssertNull (document.DocumentElement);
+			document.LoadXml ("<foo/>");
+			AssertNotNull (document.DocumentElement);
 
-			AssertSame(document.FirstChild, document.DocumentElement);
-			AssertSame(document.ChildNodes[0], document.DocumentElement);
+			AssertSame (document.FirstChild, document.DocumentElement);
+			AssertSame (document.ChildNodes [0], document.DocumentElement);
 		}
 
-		public void TestLoadXmlExceptionClearsDocument()
+		public void TestLoadXmlExceptionClearsDocument ()
 		{
-			document.LoadXml("<foo/>");
-			Assert(document.ChildNodes.Count > 0);
+			document.LoadXml ("<foo/>");
+			Assert (document.ChildNodes.Count > 0);
 			
-			try 
-			{
-				document.LoadXml("<123/>");
-				Fail("An XmlException should have been thrown.");
-			}
-			catch (XmlException) {}
-
-			Assert(document.ChildNodes.Count == 0);
+			try {
+				document.LoadXml ("<123/>");
+				Fail ("An XmlException should have been thrown.");
+			} catch (XmlException) {}
+
+			Assert (document.ChildNodes.Count == 0);
 		}
 
-		public void TestLoadXmlElementWithChildElement()
+		public void TestLoadXmlElementWithChildElement ()
 		{
-			document.LoadXml("<foo><bar/></foo>");
-			Assert(document.ChildNodes.Count == 1);
-			Assert(document.ChildNodes[0].ChildNodes.Count == 1);
-			AssertEquals("foo", document.DocumentElement.LocalName);
-			AssertEquals("bar", document.DocumentElement.ChildNodes[0].LocalName);
+			document.LoadXml ("<foo><bar/></foo>");
+			Assert (document.ChildNodes.Count == 1);
+			Assert (document.ChildNodes [0].ChildNodes.Count == 1);
+			AssertEquals ("foo", document.DocumentElement.LocalName);
+			AssertEquals ("bar", document.DocumentElement.ChildNodes [0].LocalName);
 		}
 
-		public void TestLoadXmlElementWithTextNode()
+		public void TestLoadXmlElementWithTextNode ()
 		{
-// XmlText isn't implemented yet and XmlDocument.CreateTextNode isn't either.
-//			document.LoadXml("<foo>bar</foo>");
-//			AssertEquals("bar", document.DocumentElement.ChildNodes[0].LocalName);
-//			Assert(document.DocumentElement.ChildNodes[0].NodeType == XmlNodeType.Text);
+			document.LoadXml ("<foo>bar</foo>");
+			Assert (document.DocumentElement.ChildNodes [0].NodeType == XmlNodeType.Text);
+			AssertEquals ("bar", document.DocumentElement.ChildNodes [0].Value);
 		}
 
-		public void TestDocumentElement()
+		public void TestDocumentElement ()
 		{
-			AssertNull(document.DocumentElement);
-			XmlElement element = document.CreateElement("foo", "bar", "http://foo/");
-			AssertNotNull(element);
+			AssertNull (document.DocumentElement);
+			XmlElement element = document.CreateElement ("foo", "bar", "http://foo/");
+			AssertNotNull (element);
+
+			AssertEquals ("foo", element.Prefix);
+			AssertEquals ("bar", element.LocalName);
+			AssertEquals ("http://foo/", element.NamespaceURI);
+
+			AssertEquals ("foo:bar", element.Name);
 
-			AssertEquals("foo", element.Prefix);
-			AssertEquals("bar", element.LocalName);
-			AssertEquals("http://foo/", element.NamespaceURI);
+			AssertSame (element, document.AppendChild (element));
 
-			AssertEquals("foo:bar", element.Name);
+			AssertSame (element, document.DocumentElement);
+		}
+
+		public void TestLoadXmlElementWithAttributes ()
+		{
+			AssertNull (document.DocumentElement);
+			document.LoadXml ("<foo bar='baz' quux='quuux'/>");
 
-			AssertSame(element, document.AppendChild(element));
+			XmlElement documentElement = document.DocumentElement;
 
-			AssertSame(element, document.DocumentElement);
+			AssertEquals ("baz", documentElement.GetAttribute ("bar"));
+			AssertEquals ("quuux", documentElement.GetAttribute ("quux"));
 		}
 	}
 }

+ 52 - 0
mcs/class/System.XML/Test/XmlTextReaderTests.cs

@@ -1632,5 +1632,57 @@ namespace Ximian.Mono.Tests
 			Assert (XmlReader.IsNameToken ("1foo"));
 			Assert (!XmlReader.IsNameToken (" foo"));
 		}
+
+		public void TestMoveToNextAttribute()
+		{
+			string xml = @"<foo bar=""baz"" quux='quuux'/>";
+			XmlReader xmlReader =
+				new XmlTextReader (new StringReader (xml));
+
+			AssertStartDocument (xmlReader);
+
+			AssertNode (
+				xmlReader, // xmlReader
+				XmlNodeType.Element, // nodeType
+				0, //depth
+				true, // isEmptyElement
+				"foo", // name
+				String.Empty, // prefix
+				"foo", // localName
+				String.Empty, // namespaceURI
+				String.Empty, // value
+				2 // attributeCount
+			);
+
+			AssertAttribute (
+				xmlReader, // xmlReader
+				"bar", // name
+				String.Empty, // prefix
+				"bar", // localName
+				String.Empty, // namespaceURI
+				"baz" // value
+			);
+
+			AssertAttribute (
+				xmlReader, // xmlReader
+				"quux", // name
+				String.Empty, // prefix
+				"quux", // localName
+				String.Empty, // namespaceURI
+				"quuux" // value
+			);
+
+			Assert (xmlReader.MoveToNextAttribute ());
+			Assert ("bar" == xmlReader.Name || "quux" == xmlReader.Name);
+			Assert ("baz" == xmlReader.Value || "quuux" == xmlReader.Value);
+
+			Assert (xmlReader.MoveToNextAttribute ());
+			Assert ("bar" == xmlReader.Name || "quux" == xmlReader.Name);
+			Assert ("baz" == xmlReader.Value || "quuux" == xmlReader.Value);
+
+			Assert (!xmlReader.MoveToNextAttribute ());
+
+			AssertEndDocument (xmlReader);
+		}
 	}
 }