2002-03-11 Duncan Mak <duncan@ximian.com>
[mono.git] / mcs / class / System.XML / System.Xml / XmlElement.cs
index 3419ab9a7c0757a3b937b2b5a6d134809515f979..670b514c9f307be8c1bd3bf17123480fb868102b 100644 (file)
-// -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 //
-// System.Xml.XmlElement
+// System.Xml.XmlAttribute
 //
 // Author:
-//   Daniel Weber (daniel-weber@austin.rr.com)
+//   Jason Diamond (jason@injektilo.org)
 //
-// (C) 2001 Daniel Weber
+// (C) 2002 Jason Diamond  http://injektilo.org/
+//
+
 using System;
 
 namespace System.Xml
 {
        public class XmlElement : XmlLinkedNode
        {
-               // Private/Protected internal data structures
-               //===========================================================================
-               private XmlAttributeCollection _attributes;
+               #region Fields
 
-               private string prefix;
+               private XmlAttributeCollection attributes;
+               private XmlLinkedNode lastLinkedChild;
                private string localName;
                private string namespaceURI;
+               private string prefix;
+
+               #endregion
 
-               // Public Properties
-               //===========================================================================
+               #region Constructor
 
-               /// <summary>
-               /// Return the XmlAttributeCollection on the Element
-               /// </summary>
-               public override XmlAttributeCollection Attributes
+               protected internal XmlElement (
+                       string prefix, 
+                       string localName, 
+                       string namespaceURI, 
+                       XmlDocument doc) : base (doc)
                {
-                       get
-                       {
-                               // TODO - implement Attributes
-                               return _attributes;
+                       this.prefix = prefix;
+                       this.localName = localName;
+                       this.namespaceURI = namespaceURI;
+
+                       attributes = new XmlAttributeCollection (this);
+               }
+
+               #endregion
+
+               #region Properties
+
+               public override XmlAttributeCollection Attributes {
+                       get { 
+                               return attributes; 
+                       }
+               }
+
+               public virtual bool HasAttributes {
+                       get { 
+                               return attributes.Count > 0; 
+                       }
+               }
+
+               [MonoTODO]
+               public override string InnerText {
+                       get { 
+                               throw new NotImplementedException (); 
+                       }
+
+                       set { 
+                               throw new NotImplementedException (); 
+                       }
+               }
+
+               [MonoTODO]
+               public override string InnerXml {
+                       get { 
+                               throw new NotImplementedException (); 
+                       }
+
+                       set { 
+                               throw new NotImplementedException (); 
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsEmpty     {
+                       get { 
+                               throw new NotImplementedException (); 
+                       }
+
+                       set { 
+                               throw new NotImplementedException (); 
                        }
                }
 
-               /// <summary>
-               /// Get/Set the value for this node
-               /// </summary>
-               public override string Value
+               internal override XmlLinkedNode LastLinkedChild {
+                       get     {
+                               return lastLinkedChild;
+                       }
+
+                       set {
+                               lastLinkedChild = value;
+                       }
+               }
+               
+               public override string LocalName 
                {
-                       get
-                       {
-                               return null;
+                       get { 
+                               return localName; 
                        }
+               }
+
+               public override string Name {
+                       get { 
+                               return prefix != String.Empty ? prefix + ":" + localName : localName; 
+                       }
+               }
 
-                       set
-                       {
-                               // Do nothing, can't set value on XmlElement...
+               public override string NamespaceURI {
+                       get { 
+                               return namespaceURI; 
                        }
                }
 
-               // Implement abstract methods of XmlNode
-               //=====================================================================
-               /// <summary>
-               /// Remove all children and attributes.  If
-               /// </summary>
-               public override void RemoveAll()
+               [MonoTODO]
+               public override XmlNode NextSibling {
+                       get { 
+                               return base.NextSibling; 
+                       }
+               }
+
+               public override XmlNodeType NodeType {
+                       get { 
+                               return XmlNodeType.Element; 
+                       }
+               }
+
+               [MonoTODO]
+               public override XmlDocument OwnerDocument {
+                       get { 
+                               return base.OwnerDocument; 
+                       }
+               }
+
+               public override string Prefix {
+                       get { 
+                               return prefix; 
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               [MonoTODO]
+               public override XmlNode CloneNode (bool deep)
                {
-                       // Remove all child nodes
-                       base.RemoveAll();
+                       throw new NotImplementedException ();
+               }
 
-                       // Remove all attributes
-                       _attributes.RemoveAll();
+               [MonoTODO]
+               public virtual string GetAttribute (string name)
+               {
+                       XmlNode attributeNode = Attributes.GetNamedItem (name);
+                       return attributeNode != null ? attributeNode.Value : String.Empty;
+               }
 
-                       // If we have any default attributes, add them back in with the
-                       //      appropriate namespace, baseURI, name, localName
-                       // TODO - implement adding default attributes back in XmlElement.RemoveAll()
+               [MonoTODO]
+               public virtual string GetAttribute (string localName, string namespaceURI)
+               {
+                       throw new NotImplementedException ();
                }
 
-               /// <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)
+               [MonoTODO]
+               public virtual XmlAttribute GetAttributeNode (string name)
                {
-                       // TODO - implement CloneNode()
-                       throw new NotImplementedException();
+                       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)
+               [MonoTODO]
+               public virtual XmlAttribute GetAttributeNode (string localName, string namespaceURI)
                {
-                       // TODO - implement WriteContentsTo(XmlWriter)
-                       throw new NotImplementedException();
+                       throw new NotImplementedException ();
                }
 
-               /// <summary>
-               /// Saves the current node to writer w
-               /// </summary>
-               /// <param name="w"></param>
-               public override void WriteTo(XmlWriter w)
+               [MonoTODO]
+               public virtual XmlNodeList GetElementsByTagName (string name)
                {
-                       // TODO - implement WriteTo(XmlWriter)
-                       throw new NotImplementedException();
+                       throw new NotImplementedException ();
                }
 
-               /// <summary>
-               /// Returns the local name of the node with qualifiers removed
-               /// LocalName of ns:elementName = "elementName"
-               /// </summary>
-               public override string LocalName
+               [MonoTODO]
+               public virtual XmlNodeList GetElementsByTagName (string localName, string namespaceURI)
                {
-                       get {
-                               return localName;
-                       }
+                       throw new NotImplementedException ();
                }
 
+               [MonoTODO]
+               public virtual bool HasAttribute (string name)
+               {
+                       throw new NotImplementedException ();
+               }
 
-               /// <summary>
-               /// Get the qualified node name
-               /// derived classes must implement as behavior varies
-               /// by tag type.
-               /// </summary>
-               public override string Name
+               [MonoTODO]
+               public virtual bool HasAttribute (string localName, string namespaceURI)
                {
-                       get
-                       {
-                               return prefix != String.Empty ? prefix + ":" + localName : localName;
-                       }
+                       throw new NotImplementedException ();
                }
 
-               public override string NamespaceURI
+               [MonoTODO ("Don't remove default attributes.")]
+               public override void RemoveAll ()
                {
-                       get
-                       {
-                               return namespaceURI;
-                       }
+                       // Remove the child nodes.
+                       base.RemoveAll ();
+
+                       // Remove all attributes.
+                       attributes.RemoveAll ();
                }
 
-               public override XmlNodeType NodeType
+               [MonoTODO]
+               public virtual void RemoveAllAttributes ()
                {
-                       get
-                       {
-                               return XmlNodeType.Element;
-                       }
+                       throw new NotImplementedException ();
                }
 
-               public override string Prefix
+               [MonoTODO]
+               public virtual void RemoveAttribute (string name)
                {
-                       get
-                       {
-                               return prefix;
-                       }
+                       throw new NotImplementedException ();
                }
 
+               [MonoTODO]
+               public virtual void RemoveAttribute (string localName, string namespaceURI)
+               {
+                       throw new NotImplementedException ();
+               }
 
-               // ============= Internal calls =============================================
+               [MonoTODO]
+               public virtual XmlNode RemoveAttributeAt (int i)
+               {
+                       throw new NotImplementedException ();
+               }
 
-               // Constructors
-               // ==========================================================================
-               protected internal XmlElement(string prefix, string localName, string namespaceURI, XmlDocument doc) : base(doc)
+               [MonoTODO]
+               public virtual XmlAttribute RemoveAttributeNode (XmlAttribute oldAttr)
                {
-                       this.prefix = prefix;
-                       this.localName = localName;
-                       this.namespaceURI = namespaceURI;
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual XmlAttribute RemoveAttributeNode (string localName, string namespaceURI)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual void SetAttribute (string name, string value)
+               {
+                       XmlAttribute attribute = OwnerDocument.CreateAttribute (name);
+                       attribute.SetOwnerElement (this);
+                       attribute.Value = value;
+                       Attributes.SetNamedItem (attribute);
+               }
+
+               [MonoTODO]
+               public virtual void SetAttribute (string localName, string namespaceURI, string value)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual XmlAttribute SetAttributeNode (XmlAttribute newAttr)
+               {
+                       throw new NotImplementedException ();
+               }
 
-                       _attributes = new XmlAttributeCollection(doc, this, null);
+               [MonoTODO]
+               public virtual XmlAttribute SetAttributeNode (string localName, string namespaceURI)
+               {
+                       throw new NotImplementedException ();
                }
 
+               [MonoTODO]
+               public override void WriteContentTo (XmlWriter w)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override void WriteTo (XmlWriter w)
+               {
+                       throw new NotImplementedException ();
+               }
 
-               } // class
-       }  //namespace
+               #endregion
+       }
+}