dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System.Xml ElementList.cs,NONE,1.1 Xm


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Xml ElementList.cs,NONE,1.1 XmlDocument.cs,1.7,1.8 XmlElement.cs,1.5,1.6 XmlNode.cs,1.11,1.12 XmlProcessingInstruction.cs,1.2,1.3
Date: Sun, 08 Dec 2002 23:04:06 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Xml
In directory subversions:/tmp/cvs-serv5997/System.Xml

Modified Files:
        XmlDocument.cs XmlElement.cs XmlNode.cs 
        XmlProcessingInstruction.cs 
Added Files:
        ElementList.cs 
Log Message:


Continue implementing the "System.Xml" namespace.


--- NEW FILE ---
/*
 * ElementList.cs - Implementation of the "System.Xml.ElementList" class.
 *
 * Copyright (C) 2002 Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Xml
{

using System;
using System.Collections;

internal class ElementList : XmlNodeList
{
        // Internal state.
        private XmlElement element;
        private String name;
        private String namespaceURI;
        private bool uriForm;

        // Create a new element list.
        public ElementList(XmlElement element, String name)
                        {
                                this.element = element;
                                this.name = name;
                                this.namespaceURI = null;
                                this.uriForm = false;
                        }
        public ElementList(XmlElement element, String localName,
                                           String namespaceURI)
                        {
                                this.element = element;
                                this.name = localName;
                                this.namespaceURI = namespaceURI;
                                this.uriForm = true;
                        }

        // Get the number of entries in the node list.
        [TODO]
        public override int Count
                        {
                                get
                                {
                                        // TODO
                                        return 0;
                                }
                        }

        // Get a particular item within this node list.
        [TODO]
        public override XmlNode Item(int i)
                        {
                                // TODO
                                return null;
                        }

        // Implement the "IEnumerable" interface.
        [TODO]
        public override IEnumerator GetEnumerator()
                        {
                                // TODO
                                return null;
                        }

}; // class ElementList

}; // namespace System.Xml

Index: XmlDocument.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlDocument.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** XmlDocument.cs      7 Dec 2002 07:34:14 -0000       1.7
--- XmlDocument.cs      9 Dec 2002 04:04:04 -0000       1.8
***************
*** 135,149 ****
  
        // Get the markup that represents the children of this node.
-       [TODO]
        public override String InnerXml
                        {
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                                set
                                {
!                                       // TODO
                                }
                        }
--- 135,147 ----
  
        // Get the markup that represents the children of this node.
        public override String InnerXml
                        {
                                get
                                {
!                                       return base.InnerXml;
                                }
                                set
                                {
!                                       LoadXml(value);
                                }
                        }

Index: XmlElement.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlElement.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** XmlElement.cs       6 Dec 2002 04:58:32 -0000       1.5
--- XmlElement.cs       9 Dec 2002 04:04:04 -0000       1.6
***************
*** 41,45 ****
                        {
                                this.name = name;
!                               this.attributes = new 
XmlAttributeCollection(this);
                                this.isEmpty = true;
                        }
--- 41,45 ----
                        {
                                this.name = name;
!                               this.attributes = null;
                                this.isEmpty = true;
                        }
***************
*** 50,53 ****
--- 50,57 ----
                                get
                                {
+                                       if(attributes == null)
+                                       {
+                                               attributes = new 
XmlAttributeCollection(this);
+                                       }
                                        return attributes;
                                }
***************
*** 59,78 ****
                                get
                                {
!                                       return (attributes.Count != 0);
                                }
                        }
  
        // Get the inner text version of this node.
-       [TODO]
        public override String InnerText
                        {
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                                set
                                {
!                                       // TODO
                                }
                        }
--- 63,93 ----
                                get
                                {
!                                       return (attributes != null && 
attributes.Count != 0);
                                }
                        }
  
        // Get the inner text version of this node.
        public override String InnerText
                        {
                                get
                                {
!                                       return base.InnerText;
                                }
                                set
                                {
!                                       XmlNode child = 
NodeList.GetFirstChild(this);
!                                       if(child != null &&
!                                          NodeList.GetNextSibling(child) == 
null &&
!                                          child.NodeType == XmlNodeType.Text)
!                                       {
!                                               // Special-case the case of a 
single text child.
!                                               child.Value = value;
!                                       }
!                                       else
!                                       {
!                                               // Remove the children and 
create a new text node.
!                                               RemoveAll();
!                                               
AppendChild(OwnerDocument.CreateTextNode(value));
!                                       }
                                }
                        }
***************
*** 84,89 ****
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                                set
--- 99,103 ----
                                get
                                {
!                                       return base.InnerXml;
                                }
                                set
***************
*** 179,253 ****
  
        // Clone this node in either shallow or deep mode.
-       [TODO]
        public override XmlNode CloneNode(bool deep)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get the value of an attribute with a specific name.
-       [TODO]
        public virtual String GetAttribute(String name)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get the value of an attribute with a specific name and namespace.
-       [TODO]
        public virtual String GetAttribute(String localName, String 
namespaceURI)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get the node of an attribute with a specific name.
-       [TODO]
        public virtual XmlAttribute GetAttributeNode(String name)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get the node of an attribute with a specific name and namespace.
-       [TODO]
        public virtual XmlAttribute GetAttributeNode
                                (String localName, String namespaceURI)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get a list of all descendents that match a particular name.
-       [TODO]
        public virtual XmlNodeList GetElementsByTagName(String name)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Get a list of all descendents that match a particular name and 
namespace.
-       [TODO]
        public virtual XmlNodeList GetElementsByTagName
                                (String localName, String namespaceURI)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Determine if this element has a particular attribute.
-       [TODO]
        public virtual bool HasAttribute(String name)
                        {
!                               // TODO
!                               return false;
                        }
  
        // Determine if this element has a particular attribute.
-       [TODO]
        public virtual bool HasAttribute(String localName, String namespaceURI)
                        {
!                               // TODO
!                               return false;
                        }
  
--- 193,294 ----
  
        // Clone this node in either shallow or deep mode.
        public override XmlNode CloneNode(bool deep)
                        {
!                               XmlElement clone = OwnerDocument.CreateElement
!                                       (Prefix, LocalName, NamespaceURI);
!                               clone.isEmpty = isEmpty;
!                               if(attributes != null)
!                               {
!                                       foreach(XmlAttribute attr in Attributes)
!                                       {
!                                               clone.Attributes.Append
!                                                       
((XmlAttribute)(attr.CloneNode(true)));
!                                       }
!                               }
!                               if(deep)
!                               {
!                                       clone.CloneChildrenFrom(this, deep);
!                               }
!                               return clone;
                        }
  
        // Get the value of an attribute with a specific name.
        public virtual String GetAttribute(String name)
                        {
!                               XmlAttribute attr = GetAttributeNode(name);
!                               if(attr != null)
!                               {
!                                       return attr.Value;
!                               }
!                               else
!                               {
!                                       return String.Empty;
!                               }
                        }
  
        // Get the value of an attribute with a specific name and namespace.
        public virtual String GetAttribute(String localName, String 
namespaceURI)
                        {
!                               XmlAttribute attr = GetAttributeNode(localName, 
namespaceURI);
!                               if(attr != null)
!                               {
!                                       return attr.Value;
!                               }
!                               else
!                               {
!                                       return String.Empty;
!                               }
                        }
  
        // Get the node of an attribute with a specific name.
        public virtual XmlAttribute GetAttributeNode(String name)
                        {
!                               if(attributes != null)
!                               {
!                                       return attributes[name];
!                               }
!                               else
!                               {
!                                       return null;
!                               }
                        }
  
        // Get the node of an attribute with a specific name and namespace.
        public virtual XmlAttribute GetAttributeNode
                                (String localName, String namespaceURI)
                        {
!                               if(attributes != null)
!                               {
!                                       return attributes[localName, 
namespaceURI];
!                               }
!                               else
!                               {
!                                       return null;
!                               }
                        }
  
        // Get a list of all descendents that match a particular name.
        public virtual XmlNodeList GetElementsByTagName(String name)
                        {
!                               return new ElementList(this, name);
                        }
  
        // Get a list of all descendents that match a particular name and 
namespace.
        public virtual XmlNodeList GetElementsByTagName
                                (String localName, String namespaceURI)
                        {
!                               return new ElementList(this, localName, 
namespaceURI);
                        }
  
        // Determine if this element has a particular attribute.
        public virtual bool HasAttribute(String name)
                        {
!                               return (GetAttributeNode(name) != null);
                        }
  
        // Determine if this element has a particular attribute.
        public virtual bool HasAttribute(String localName, String namespaceURI)
                        {
!                               return (GetAttributeNode(localName, 
namespaceURI) != null);
                        }
  
***************
*** 260,352 ****
  
        // Remove all of the attributes from this node.
-       [TODO]
        public virtual void RemoveAllAttributes()
                        {
!                               // TODO
                        }
  
        // Remove a specified attribute by name.
-       [TODO]
        public virtual void RemoveAttribute(String name)
                        {
!                               // TODO
                        }
  
        // Remove a specified attribute by name and namespace.
-       [TODO]
        public virtual void RemoveAttribute(String localName, String 
namespaceURI)
                        {
!                               // TODO
                        }
  
        // Remove a specified attribute by index.
-       [TODO]
        public virtual XmlNode RemoveAttributeAt(int i)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Remove a particular attribute node and return the node.
-       [TODO]
        public virtual XmlAttribute RemoveAttributeNode(XmlAttribute oldAttr)
                        {
!                               // TODO
!                               return oldAttr;
                        }
  
        // Remove a particular attribute by name and return the node.
-       [TODO]
        public virtual XmlAttribute RemoveAttributeNode
                                (String localName, String namespaceURI)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Set an attribute to a specific value.
-       [TODO]
        public virtual void SetAttribute(String name, String value)
                        {
!                               // TODO
                        }
  
        // Set an attribute to a specific value.
-       [TODO]
        public virtual void SetAttribute(String localName, String namespaceURI,
                                                                         String 
value)
                        {
!                               // TODO
                        }
  
        // Set an attribute by node.
-       [TODO]
        public virtual XmlAttribute SetAttributeNode(XmlAttribute newAttr)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Create a new attribute node and return it.
-       [TODO]
        public virtual XmlAttribute SetAttributeNode
                                (String localName, String namespaceURI)
                        {
!                               // TODO
!                               return null;
                        }
  
        // Writes the contents of this node to a specified XmlWriter.
-       [TODO]
        public override void WriteContentTo(XmlWriter w)
                        {
!                               // TODO
                        }
  
        // Write this node and all of its contents to a specified XmlWriter.
-       [TODO]
        public override void WriteTo(XmlWriter w)
                        {
!                               // TODO
                        }
  
--- 301,459 ----
  
        // Remove all of the attributes from this node.
        public virtual void RemoveAllAttributes()
                        {
!                               if(attributes != null)
!                               {
!                                       attributes.RemoveAll();
!                               }
                        }
  
        // Remove a specified attribute by name.
        public virtual void RemoveAttribute(String name)
                        {
!                               if(attributes != null)
!                               {
!                                       attributes.RemoveNamedItem(name);
!                               }
                        }
  
        // Remove a specified attribute by name and namespace.
        public virtual void RemoveAttribute(String localName, String 
namespaceURI)
                        {
!                               if(attributes != null)
!                               {
!                                       attributes.RemoveNamedItem(localName, 
namespaceURI);
!                               }
                        }
  
        // Remove a specified attribute by index.
        public virtual XmlNode RemoveAttributeAt(int i)
                        {
!                               if(attributes != null)
!                               {
!                                       return attributes.RemoveAt(i);
!                               }
!                               else
!                               {
!                                       return null;
!                               }
                        }
  
        // Remove a particular attribute node and return the node.
        public virtual XmlAttribute RemoveAttributeNode(XmlAttribute oldAttr)
                        {
!                               if(attributes != null)
!                               {
!                                       return 
(XmlAttribute)(attributes.Remove(oldAttr));
!                               }
!                               else
!                               {
!                                       return null;
!                               }
                        }
  
        // Remove a particular attribute by name and return the node.
        public virtual XmlAttribute RemoveAttributeNode
                                (String localName, String namespaceURI)
                        {
!                               if(attributes != null)
!                               {
!                                       return 
(XmlAttribute)(attributes.RemoveNamedItem
!                                                               (localName, 
namespaceURI));
!                               }
!                               else
!                               {
!                                       return null;
!                               }
                        }
  
        // Set an attribute to a specific value.
        public virtual void SetAttribute(String name, String value)
                        {
!                               XmlAttribute attr = GetAttributeNode(name);
!                               if(attr != null)
!                               {
!                                       attr.Value = value;
!                               }
!                               else
!                               {
!                                       attr = 
OwnerDocument.CreateAttribute(name);
!                                       attr.Value = value;
!                                       Attributes.Append(attr);
!                               }
                        }
  
        // Set an attribute to a specific value.
        public virtual void SetAttribute(String localName, String namespaceURI,
                                                                         String 
value)
                        {
!                               XmlAttribute attr = GetAttributeNode(localName, 
namespaceURI);
!                               if(attr != null)
!                               {
!                                       attr.Value = value;
!                               }
!                               else
!                               {
!                                       attr = OwnerDocument.CreateAttribute
!                                               (localName, namespaceURI);
!                                       attr.Value = value;
!                                       Attributes.Append(attr);
!                               }
                        }
  
        // Set an attribute by node.
        public virtual XmlAttribute SetAttributeNode(XmlAttribute newAttr)
                        {
!                               if(newAttr.OwnerElement == null)
!                               {
!                                       return 
(XmlAttribute)(Attributes.SetNamedItem(newAttr));
!                               }
!                               else
!                               {
!                                       throw new InvalidOperationException
!                                               (S._("Xml_AttrAlreadySet"));
!                               }
                        }
  
        // Create a new attribute node and return it.
        public virtual XmlAttribute SetAttributeNode
                                (String localName, String namespaceURI)
                        {
!                               XmlAttribute attr = GetAttributeNode(localName, 
namespaceURI);
!                               if(attr != null)
!                               {
!                                       attr = OwnerDocument.CreateAttribute
!                                               (localName, namespaceURI);
!                                       Attributes.Append(attr);
!                               }
!                               return attr;
                        }
  
        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
!                               WriteChildrenTo(w);
                        }
  
        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
!                               w.WriteStartElement(Prefix, LocalName, 
NamespaceURI);
!                               if(attributes != null)
!                               {
!                                       foreach(XmlAttribute attr in attributes)
!                                       {
!                                               attr.WriteTo(w);
!                                       }
!                               }
!                               if(!isEmpty)
!                               {
!                                       WriteContentTo(w);
!                                       w.WriteFullEndElement();
!                               }
!                               else
!                               {
!                                       w.WriteEndElement();
!                               }
                        }
  

Index: XmlNode.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlNode.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** XmlNode.cs  6 Dec 2002 04:58:32 -0000       1.11
--- XmlNode.cs  9 Dec 2002 04:04:04 -0000       1.12
***************
*** 810,817 ****
  
        // Normalize the text nodes underneath this node.
-       [TODO]
        public virtual void Normalize()
                        {
!                               // TODO
                        }
  
--- 810,870 ----
  
        // Normalize the text nodes underneath this node.
        public virtual void Normalize()
                        {
!                               XmlNode current = NodeList.GetFirstChild(this);
!                               XmlNode next, setNode;
!                               StringBuilder builder = null;
!                               setNode = null;
!                               while(current != null)
!                               {
!                                       next = NodeList.GetNextSibling(this);
!                                       switch(current.NodeType)
!                                       {
!                                               case XmlNodeType.Text:
!                                               case XmlNodeType.Whitespace:
!                                               case 
XmlNodeType.SignificantWhitespace:
!                                               {
!                                                       if(setNode != null)
!                                                       {
!                                                               
builder.Append(current.Value);
!                                                               
RemoveChild(current);
!                                                       }
!                                                       else
!                                                       {
!                                                               setNode = 
current;
!                                                               builder = new 
StringBuilder(current.Value);
!                                                       }
!                                               }
!                                               break;
! 
!                                               case XmlNodeType.Element:
!                                               {
!                                                       if(setNode != null)
!                                                       {
!                                                               setNode.Value = 
builder.ToString();
!                                                               setNode = null;
!                                                               builder = null;
!                                                       }
!                                                       current.Normalize();
!                                               }
!                                               break;
! 
!                                               default:
!                                               {
!                                                       if(setNode != null)
!                                                       {
!                                                               setNode.Value = 
builder.ToString();
!                                                               setNode = null;
!                                                               builder = null;
!                                                       }
!                                               }
!                                               break;
!                                       }
!                                       current = next;
!                               }
!                               if(setNode != null)
!                               {
!                                       setNode.Value = builder.ToString();
!                               }
                        }
  
***************
*** 940,947 ****
  
        // Replace a child of this node.
-       [TODO]
        public virtual XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild)
                        {
!                               // TODO
                                return oldChild;
                        }
--- 993,1001 ----
  
        // Replace a child of this node.
        public virtual XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild)
                        {
!                               XmlNode next = oldChild.NextSibling;
!                               RemoveChild(oldChild);
!                               InsertBefore(newChild, next);
                                return oldChild;
                        }

Index: XmlProcessingInstruction.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlProcessingInstruction.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** XmlProcessingInstruction.cs 6 Dec 2002 04:58:32 -0000       1.2
--- XmlProcessingInstruction.cs 9 Dec 2002 04:04:04 -0000       1.3
***************
*** 46,50 ****
  
        // Get or set the data associated with a processing instruction.
-       [TODO]
        public String Data
                        {
--- 46,49 ----
***************
*** 55,75 ****
                                set
                                {
!                                       // TODO: change events
                                        data = value;
                                }
                        }
  
        // Get or set the inner text associated with this processing 
instruction.
-       [TODO]
        public override String InnerText
                        {
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                                set
                                {
!                                       // TODO
                                }
                        }
--- 54,74 ----
                                set
                                {
!                                       XmlNodeChangedEventArgs args;
!                                       args = 
EmitBefore(XmlNodeChangedAction.Change);
                                        data = value;
+                                       EmitAfter(args);
                                }
                        }
  
        // Get or set the inner text associated with this processing 
instruction.
        public override String InnerText
                        {
                                get
                                {
!                                       return Data;
                                }
                                set
                                {
!                                       Data = value;
                                }
                        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]