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 XmlCDataSection.cs,NONE,1.


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Xml XmlCDataSection.cs,NONE,1.1 XmlCharacterData.cs,NONE,1.1 XmlComment.cs,NONE,1.1 XmlDeclaration.cs,NONE,1.1 XmlNamedNodeMap.cs,NONE,1.1 XmlQualifiedName.cs,NONE,1.1 XmlSignificantWhitespace.cs,NONE,1.1 XmlText.cs,NONE,1.1 XmlWhitespace.cs,NONE,1.1 XmlAttributeCollection.cs,1.2,1.3 XmlDocument.cs,1.2,1.3 XmlDocumentType.cs,1.1,1.2 XmlElement.cs,1.1,1.2 XmlNode.cs,1.8,1.9
Date: Tue, 03 Dec 2002 23:46:37 -0500

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

Modified Files:
        XmlAttributeCollection.cs XmlDocument.cs XmlDocumentType.cs 
        XmlElement.cs XmlNode.cs 
Added Files:
        XmlCDataSection.cs XmlCharacterData.cs XmlComment.cs 
        XmlDeclaration.cs XmlNamedNodeMap.cs XmlQualifiedName.cs 
        XmlSignificantWhitespace.cs XmlText.cs XmlWhitespace.cs 
Log Message:


Implement many of the DOM node types in the "System.Xml" namespace.


--- NEW FILE ---
/*
 * XmlCDataSection.cs - Implementation of the
 *              "System.Xml.XmlCDataSection" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlCDataSection : XmlCharacterData
{
        // Constructor.
        internal XmlCDataSection(XmlNode parent, String data)
                        : base(parent, data)
                        {
                                // Nothing to do here.
                        }

        // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
                                        return "#cdata-section";
                                }
                        }

        // Get the qualified name of this node.
        public override String Name
                        {
                                get
                                {
                                        return "#cdata-section";
                                }
                        }

        // Get the node type.
        public override XmlNodeType NodeType
                        {
                                get
                                {
                                        return XmlNodeType.CDATA;
                                }
                        }

        // Clone this node.
        public override XmlNode CloneNode(bool deep)
                        {
                                return OwnerDocument.CreateCDataSection(Data);
                        }

        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
                                // Nothing needs to be done here for CDATA 
nodes.
                        }

        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                w.WriteCData(Data);
                        }

}; // class XmlCDataSection

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlCharacterData.cs - Implementation of the
 *              "System.Xml.XmlCharacterData" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
abstract class XmlCharacterData : XmlLinkedNode
{
        // Internal state.  May be either "String" or "StringBuilder".
        private Object data;

        // Constructor.
        internal XmlCharacterData(XmlNode parent, String data)
                        : base(parent)
                        {
                                this.data = data;
                        }

        // Get or set the data in this node.
        public virtual String Data
                        {
                                get
                                {
                                        return GetString();
                                }
                                set
                                {
                                        XmlNodeChangedEventArgs args;
                                        args = 
EmitBefore(XmlNodeChangedAction.Change);
                                        data = value;
                                        EmitAfter(args);
                                }
                        }

        // Get or set the inner text for this node.
        public override String InnerText
                        {
                                get
                                {
                                        return Value;
                                }
                                set
                                {
                                        Value = value;
                                }
                        }

        // Get the length of the character data.
        public virtual int Length
                        {
                                get
                                {
                                        if(data == null)
                                        {
                                                return 0;
                                        }
                                        else if(data is StringBuilder)
                                        {
                                                return 
((StringBuilder)data).Length;
                                        }
                                        else
                                        {
                                                return ((String)data).Length;
                                        }
                                }
                        }

        // Get or set the value of this node.
        public override String Value
                        {
                                get
                                {
                                        return Data;
                                }
                                set
                                {
                                        Data = value;
                                }
                        }

        // Get the underlying data as a string builder.
        private StringBuilder GetBuilder()
                        {
                                StringBuilder builder;
                                if(data == null)
                                {
                                        builder = new StringBuilder();
                                }
                                else if(data is StringBuilder)
                                {
                                        return (StringBuilder)data;
                                }
                                else
                                {
                                        builder = new 
StringBuilder((String)data);
                                }
                                data = builder;
                                return builder;
                        }

        // Get the underlying data as a string.
        private String GetString()
                        {
                                if(data == null)
                                {
                                        return String.Empty;
                                }
                                else if(data is StringBuilder)
                                {
                                        data = ((StringBuilder)data).ToString();
                                        return (String)data;
                                }
                                else
                                {
                                        return (String)data;
                                }
                        }

        // Append data to this node.
        public virtual void AppendData(String strData)
                        {
                                XmlNodeChangedEventArgs args;
                                args = EmitBefore(XmlNodeChangedAction.Change);
                                GetBuilder().Append(strData);
                                EmitAfter(args);
                        }

        // Delete data from this node.
        public virtual void DeleteData(int offset, int count)
                        {
                                // Clamp the range to the actual data bounds.
                                int length = Length;
                                if(offset < 0)
                                {
                                        count += offset;
                                        offset = 0;
                                }
                                else if(offset >= length)
                                {
                                        offset = length;
                                        count = 0;
                                }
                                if((length - offset) < count)
                                {
                                        count = length - offset;
                                }
                                if(count < 0)
                                {
                                        count = 0;
                                }

                                // Delete the character range.
                                XmlNodeChangedEventArgs args;
                                args = EmitBefore(XmlNodeChangedAction.Change);
                                GetBuilder().Remove(offset, count);
                                EmitAfter(args);
                        }

        // Insert data into this node.
        public virtual void InsertData(int offset, String strData)
                        {
                                XmlNodeChangedEventArgs args;
                                args = EmitBefore(XmlNodeChangedAction.Change);
                                GetBuilder().Insert(offset, strData);
                                EmitAfter(args);
                        }

        // Replace the data at a particular position within this node.
        public virtual void ReplaceData(int offset, int count, String strData)
                        {
                                XmlNodeChangedEventArgs args;
                                args = EmitBefore(XmlNodeChangedAction.Change);
                                GetBuilder().Remove(offset, count);
                                GetBuilder().Insert(offset, strData);
                                EmitAfter(args);
                        }

        // Retrieve a substring.
        public virtual String Substring(int offset, int count)
                        {
                                // Clamp the range to the actual data bounds.
                                int length = Length;
                                if(offset < 0)
                                {
                                        count += offset;
                                        offset = 0;
                                }
                                else if(offset >= length)
                                {
                                        offset = length;
                                        count = 0;
                                }
                                if((length - offset) < count)
                                {
                                        count = length - offset;
                                }
                                if(count < 0)
                                {
                                        count = 0;
                                }

                                // Get the substring.
                                return GetString().Substring(offset, count);
                        }

}; // class XmlCharacterData

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlComment.cs - Implementation of the "System.Xml.XmlComment" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlComment : XmlCharacterData
{
        // Constructor.
        internal XmlComment(XmlNode parent, String text)
                        : base(parent, text)
                        {
                                // Nothing to do here.
                        }

        // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
                                        return "#comment";
                                }
                        }

        // Get the qualified name of this node.
        public override String Name
                        {
                                get
                                {
                                        return "#comment";
                                }
                        }

        // Get the node type.
        public override XmlNodeType NodeType
                        {
                                get
                                {
                                        return XmlNodeType.Comment;
                                }
                        }

        // Clone this node.
        public override XmlNode CloneNode(bool deep)
                        {
                                return OwnerDocument.CreateComment(Data);
                        }

        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
                                // Nothing needs to be done here for comment 
nodes.
                        }

        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                w.WriteComment(Data);
                        }

}; // class XmlComment

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlDeclaration.cs - Implementation of the
 *              "System.Xml.XmlDeclaration" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlDeclaration : XmlLinkedNode
{
        // Internal state.
        private String encoding;
        private String standalone;
        private String version;

        // Constructor.
        internal XmlDeclaration(XmlNode parent, String version,
                                                        String encoding, String 
standalone)
                        : base(parent)
                        {
                                Encoding = encoding;
                                Standalone = standalone;
                                if(version != "1.0")
                                {
                                        throw new ArgumentException
                                                (S._("Xml_InvalidVersion"), 
"version");
                                }
                                this.version = version;
                        }

        // Get or set the document encoding.
        public String Encoding
                        {
                                get
                                {
                                        return encoding;
                                }
                                set
                                {
                                        if(value != null)
                                        {
                                                encoding = value;
                                        }
                                        else
                                        {
                                                encoding = String.Empty;
                                        }
                                }
                        }

        // Get or set the inner text.
        public override String InnerText
                        {
                                get
                                {
                                        StringBuilder builder = new 
StringBuilder();
                                        builder.Append("version=\"");
                                        builder.Append(Version);
                                        builder.Append("\"");
                                        if(Encoding != String.Empty)
                                        {
                                                builder.Append(" encoding=\"");
                                                builder.Append(Encoding);
                                                builder.Append("\"");
                                        }
                                        if(Standalone != String.Empty)
                                        {
                                                builder.Append(" 
standalone=\"");
                                                builder.Append(Standalone);
                                                builder.Append("\"");
                                        }
                                        return builder.ToString();
                                }
                                set
                                {
                                        // TODO: parse the declaration and set 
the values.
                                }
                        }

        // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
                                        return "xml";
                                }
                        }

        // Get the qualified name of this node.
        public override String Name
                        {
                                get
                                {
                                        return "xml";
                                }
                        }

        // Get or set the standalone property of the document.
        public String Standalone
                        {
                                get
                                {
                                        return standalone;
                                }
                                set
                                {
                                        if(value == null)
                                        {
                                                standalone = String.Empty;
                                        }
                                        else if(value == String.Empty || value 
== "yes" ||
                                                        value == "no")
                                        {
                                                standalone = value;
                                        }
                                        else
                                        {
                                                throw new ArgumentException
                                                        
(S._("Xml_InvalidStandalone"), "value");
                                        }
                                }
                        }

        // Get or set the value of this node.
        public override String Value
                        {
                                get
                                {
                                        return InnerText;
                                }
                                set
                                {
                                        InnerText = value;
                                }
                        }

        // Get the XML document version.
        public String Version
                        {
                                get
                                {
                                        return version;
                                }
                        }

        // Clone this node.
        public override XmlNode CloneNode(bool deep)
                        {
                                return OwnerDocument.CreateXmlDeclaration
                                                (version, encoding, standalone);
                        }

        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
                                // Nothing needs to be done here for text nodes.
                        }

        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                w.WriteProcessingInstruction(Name, Value);
                        }

}; // class XmlDeclaration

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlNamedNodeMap.cs - Implementation of the
 *              "System.Xml.XmlNamedNodeMap" 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;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlNamedNodeMap : IEnumerable
{
        // Internal state.
        internal ArrayList map;
        private XmlNode parent;

        // Constructor.
        internal XmlNamedNodeMap(XmlNode parent)
                        {
                                this.map = new ArrayList();
                                this.parent = parent;
                        }

        // Get the number of items in the map.
        public virtual int Count
                        {
                                get
                                {
                                        return map.Count;
                                }
                        }

        // Enumerate over this map.
        public virtual IEnumerator GetEnumerator()
                        {
                                return map.GetEnumerator();
                        }

        // Get a particular node by name from this map.
        public virtual XmlNode GetNamedItem(String name)
                        {
                                if(name == null)
                                {
                                        name = String.Empty;
                                }
                                int posn, count;
                                XmlNode node;
                                count = map.Count;
                                for(posn = 0; posn < count; ++posn)
                                {
                                        node = (XmlNode)(map[posn]);
                                        if(node.Name == name)
                                        {
                                                return node;
                                        }
                                }
                                return null;
                        }
        public virtual XmlNode GetNamedItem(String localName, String 
namespaceURI)
                        {
                                if(localName == null)
                                {
                                        localName = String.Empty;
                                }
                                if(namespaceURI == null)
                                {
                                        namespaceURI = String.Empty;
                                }
                                int posn, count;
                                XmlNode node;
                                count = map.Count;
                                for(posn = 0; posn < count; ++posn)
                                {
                                        node = (XmlNode)(map[posn]);
                                        if(node.LocalName == localName &&
                                           node.NamespaceURI == namespaceURI)
                                        {
                                                return node;
                                        }
                                }
                                return null;
                        }

        // Retrieve a particular item.
        public virtual XmlNode Item(int index)
                        {
                                if(index < 0 || index >= map.Count)
                                {
                                        return null;
                                }
                                else
                                {
                                        return (XmlNode)(map[index]);
                                }
                        }

        // Remove a particular node by name from this map.
        public virtual XmlNode RemoveNamedItem(String name)
                        {
                                if(name == null)
                                {
                                        name = String.Empty;
                                }
                                int posn, count;
                                XmlNode node;
                                count = map.Count;
                                for(posn = 0; posn < count; ++posn)
                                {
                                        node = (XmlNode)(map[posn]);
                                        if(node.Name == name)
                                        {
                                                map.RemoveAt(posn);
                                                return node;
                                        }
                                }
                                return null;
                        }
        public virtual XmlNode RemoveNamedItem
                                (String localName, String namespaceURI)
                        {
                                if(localName == null)
                                {
                                        localName = String.Empty;
                                }
                                if(namespaceURI == null)
                                {
                                        namespaceURI = String.Empty;
                                }
                                int posn, count;
                                XmlNode node;
                                count = map.Count;
                                for(posn = 0; posn < count; ++posn)
                                {
                                        node = (XmlNode)(map[posn]);
                                        if(node.LocalName == localName &&
                                           node.NamespaceURI == namespaceURI)
                                        {
                                                map.RemoveAt(posn);
                                                return node;
                                        }
                                }
                                return null;
                        }

        // Set or append an item into this map.
        internal XmlNode SetOrAppend(XmlNode node, bool append)
                        {
                                XmlNode oldNode;
                                String name;
                                int posn, count;
                                if(node == null)
                                {
                                        return null;
                                }
                                if(node.OwnerDocument != parent.OwnerDocument)
                                {
                                        throw new ArgumentException
                                                (S._("Xml_NotSameDocument"), 
"node");
                                }
                                if(parent.IsReadOnly)
                                {
                                        throw new 
ArgumentException(S._("Xml_ReadOnly"));
                                }
                                count = map.Count;
                                name = node.Name;
                                for(posn = 0; posn < count; ++posn)
                                {
                                        oldNode = (XmlNode)(map[posn]);
                                        if(oldNode.Name == name)
                                        {
                                                if(append && posn < (count - 1))
                                                {
                                                        map.RemoveAt(posn);
                                                        map.Add(node);
                                                }
                                                else
                                                {
                                                        map[posn] = node;
                                                }
                                                return oldNode;
                                        }
                                }
                                map.Add(node);
                                return null;
                        }

        // Set an item into this map.
        public virtual XmlNode SetNamedItem(XmlNode node)
                        {
                                return SetOrAppend(node, false);
                        }

}; // class XmlNamedNodeMap

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlQualifiedName.cs - Implementation of the "System.Xml.XmlQualifiedName" 
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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlQualifiedName
{
        // Internal state.
        private String name;
        private String ns;
        public static readonly XmlQualifiedName Empty = new XmlQualifiedName();

        // Constructors.
        public XmlQualifiedName()
                        {
                                this.name = String.Empty;
                                this.ns = String.Empty;
                        }
        public XmlQualifiedName(String name)
                        {
                                this.name = ((name != null) ? name : 
String.Empty);
                                this.ns = String.Empty;
                        }
        public XmlQualifiedName(String name, String ns)
                        {
                                this.name = ((name != null) ? name : 
String.Empty);
                                this.ns = ((ns != null) ? ns : String.Empty);
                        }

        // Determine if this qualified name is empty.
        public bool IsEmpty
                        {
                                get
                                {
                                        return (name == String.Empty && ns == 
String.Empty);
                                }
                        }

        // Get the name from this object.
        public String Name
                        {
                                get
                                {
                                        return name;
                                }
                        }

        // Get the namespace from this object.
        public String Namespace
                        {
                                get
                                {
                                        return ns;
                                }
                        }

        // Determine if two qualified names are equal.
        public override bool Equals(Object obj)
                        {
                                XmlQualifiedName other = (obj as 
XmlQualifiedName);
                                if(other != null)
                                {
                                        return (name == other.name && ns == 
other.ns);
                                }
                                return false;
                        }

        // Get the hash code for this qualified name.
        public override int GetHashCode()
                        {
                                return name.GetHashCode();
                        }

        // Convert this qualified name into a string.
        public override String ToString()
                        {
                                if(ns.Length > 0)
                                {
                                        return ns + ":" + name;
                                }
                                else
                                {
                                        return name;
                                }
                        }

        // Convert a name/namespace pair into a qualified name.
        public static String ToString(String name, String ns)
                        {
                                if(ns != null && ns.Length > 0)
                                {
                                        return ns + ":" + ((name != null) ? 
name : String.Empty);
                                }
                                else
                                {
                                        return ((name != null) ? name : 
String.Empty);
                                }
                        }

        // Determine if two qualified names are equal.
        public static bool operator==(XmlQualifiedName a, XmlQualifiedName b)
                        {
                                if(a == null)
                                {
                                        return (b == null);
                                }
                                else if(b == null)
                                {
                                        return false;
                                }
                                else
                                {
                                        return (a.name == b.name && a.ns == 
b.ns);
                                }
                        }

        // Determine if two qualified names are not equal.
        public static bool operator!=(XmlQualifiedName a, XmlQualifiedName b)
                        {
                                if(a == null)
                                {
                                        return (b != null);
                                }
                                else if(b == null)
                                {
                                        return true;
                                }
                                else
                                {
                                        return (a.name != b.name || a.ns != 
b.ns);
                                }
                        }

}; // class XmlQualifiedName

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlSignificantWhitespace.cs - Implementation of the
 *              "System.Xml.XmlSignificantWhitespace" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlSignificantWhitespace : XmlCharacterData
{
        // Constructor.
        internal XmlSignificantWhitespace(XmlNode parent, String text)
                        : base(parent, null)
                        {
                                // Set the whitespace via "Value" so that it 
will
                                // be properly checked for whitespace 
characters.
                                if(text != null)
                                {
                                        Value = text;
                                }
                        }

        // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
                                        return "#significant-whitespace";
                                }
                        }

        // Get the qualified name of this node.
        public override String Name
                        {
                                get
                                {
                                        return "#significant-whitespace";
                                }
                        }

        // Get the node type.
        public override XmlNodeType NodeType
                        {
                                get
                                {
                                        return 
XmlNodeType.SignificantWhitespace;
                                }
                        }

        // Get or set the value of this node.
        public override String Value
                        {
                                get
                                {
                                        return Data;
                                }
                                set
                                {
                                        if(value != null)
                                        {
                                                foreach(char ch in value)
                                                {
                                                        
if(!Char.IsWhiteSpace(ch))
                                                        {
                                                                throw new 
ArgumentException
                                                                        
(S._("Xml_InvalidWhitespace"));
                                                        }
                                                }
                                        }
                                        Data = value;
                                }
                        }

        // Clone this node.
        public override XmlNode CloneNode(bool deep)
                        {
                                return 
OwnerDocument.CreateSignificantWhitespace(Data);
                        }

        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
                                // Nothing needs to be done here for whitespace 
nodes.
                        }

        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                w.WriteString(Data);
                        }

}; // class XmlSignificantWhitespace

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlText.cs - Implementation of the "System.Xml.XmlText" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlText : XmlCharacterData
{
        // Constructor.
        internal XmlText(XmlNode parent, String text)
                        : base(parent, text)
                        {
                                // Nothing to do here.
                        }

        // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
                                        return "#text";
                                }
                        }

        // Get the qualified name of this node.
        public override String Name
                        {
                                get
                                {
                                        return "#text";
                                }
                        }

        // Get the node type.
        public override XmlNodeType NodeType
                        {
                                get
                                {
                                        return XmlNodeType.Text;
                                }
                        }

        // Get or set the value of this node.
        public override String Value
                        {
                                get
                                {
                                        return Data;
                                }
                                set
                                {
                                        Data = value;
                                        // TODO: if the parent is an attribute, 
then
                                        // set its "specified" property.
                                }
                        }

        // Clone this node.
        public override XmlNode CloneNode(bool deep)
                        {
                                return OwnerDocument.CreateTextNode(Data);
                        }

        // Split this node in two.
        public virtual XmlText SplitText(int offset)
                        {
                                int length = Length;
                                if(offset < 0)
                                {
                                        offset = 0;
                                }
                                else if(offset > length)
                                {
                                        offset = length;
                                }
                                String data = Data;
                                XmlText node;
                                node = 
OwnerDocument.CreateTextNode(data.Substring(offset));
                                Data = data.Substring(0, offset);
                                parent.InsertAfter(node, this);
                                return node;
                        }

        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
                                // Nothing needs to be done here for text nodes.
                        }

        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                w.WriteString(Data);
                        }

}; // class XmlText

}; // namespace System.Xml

--- NEW FILE ---
/*
 * XmlWhitespace.cs - Implementation of the "System.Xml.XmlWhitespace" 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.Text;

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlWhitespace : XmlCharacterData
{
        // Constructor.
        internal XmlWhitespace(XmlNode parent, String text)
                        : base(parent, null)
                        {
                                // Set the whitespace via "Value" so that it 
will
                                // be properly checked for whitespace 
characters.
                                if(text != null)
                                {
                                        Value = text;
                                }
                        }

        // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
                                        return "#whitespace";
                                }
                        }

        // Get the qualified name of this node.
        public override String Name
                        {
                                get
                                {
                                        return "#whitespace";
                                }
                        }

        // Get the node type.
        public override XmlNodeType NodeType
                        {
                                get
                                {
                                        return XmlNodeType.Whitespace;
                                }
                        }

        // Get or set the value of this node.
        public override String Value
                        {
                                get
                                {
                                        return Data;
                                }
                                set
                                {
                                        if(value != null)
                                        {
                                                foreach(char ch in value)
                                                {
                                                        
if(!Char.IsWhiteSpace(ch))
                                                        {
                                                                throw new 
ArgumentException
                                                                        
(S._("Xml_InvalidWhitespace"));
                                                        }
                                                }
                                        }
                                        Data = value;
                                }
                        }

        // Clone this node.
        public override XmlNode CloneNode(bool deep)
                        {
                                return OwnerDocument.CreateWhitespace(Data);
                        }

        // Writes the contents of this node to a specified XmlWriter.
        public override void WriteContentTo(XmlWriter w)
                        {
                                // Nothing needs to be done here for whitespace 
nodes.
                        }

        // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                w.WriteWhitespace(Data);
                        }

}; // class XmlWhitespace

}; // namespace System.Xml

Index: XmlAttributeCollection.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlAttributeCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** XmlAttributeCollection.cs   3 Dec 2002 03:48:29 -0000       1.2
--- XmlAttributeCollection.cs   4 Dec 2002 04:46:35 -0000       1.3
***************
*** 24,27 ****
--- 24,29 ----
  
  using System;
+ using System.Collections;
+ using System.Runtime.CompilerServices;
  
  #if ECMA_COMPAT
***************
*** 30,42 ****
  public
  #endif
! class XmlAttributeCollection
  {
-       // TODO
  
!       public int Count { get { return 0; /* TODO */ } }
  
!       public XmlAttribute this[int i] { get { return null; } }
!       public XmlAttribute this[String name] { get { return null; } }
!       public XmlAttribute this[String name, String ns] { get { return null; } 
}
  
  }; // class XmlAttributeCollection
--- 32,224 ----
  public
  #endif
! class XmlAttributeCollection : XmlNamedNodeMap, ICollection
  {
  
!       // Constructor.
!       internal XmlAttributeCollection(XmlNode parent) : base(parent) {}
  
!       // Retrieve items from this attribute collection.
!       [IndexerName("ItemOf")]
!       public virtual XmlAttribute this[int i]
!                       {
!                               get
!                               {
!                                       return (XmlAttribute)(Item(i));
!                               }
!                       }
!       [IndexerName("ItemOf")]
!       public virtual XmlAttribute this[String name]
!                       {
!                               get
!                               {
!                                       return 
(XmlAttribute)(GetNamedItem(name));
!                               }
!                       }
!       [IndexerName("ItemOf")]
!       public virtual XmlAttribute this[String name, String ns]
!                       {
!                               get
!                               {
!                                       return 
(XmlAttribute)(GetNamedItem(name, ns));
!                               }
!                       }
! 
!       // Append an attribute to this collection.
!       public virtual XmlAttribute Append(XmlAttribute node)
!                       {
!                               SetOrAppend(node, true);
!                               return node;
!                       }
! 
!       // Copy the attributes in this collection to an array.
!       public void CopyTo(XmlAttribute[] array, int index)
!                       {
!                               int count = Count;
!                               int posn;
!                               for(posn = 0; posn < count; ++posn)
!                               {
!                                       array[index++] = 
(XmlAttribute)(Item(posn));
!                               }
!                       }
! 
!       // Get the position of a reference node within this collection
!       private int GetItemPosition(XmlAttribute refNode)
!                       {
!                               int count = Count;
!                               int posn;
!                               for(posn = 0; posn < count; ++posn)
!                               {
!                                       if(Item(posn) == refNode)
!                                       {
!                                               return posn;
!                                       }
!                               }
!                               throw new ArgumentException
!                                       (S._("Xml_NotAttrCollectionMember"), 
"refNode");
!                       }
! 
!       // Insert a node after another one.
!       public virtual XmlAttribute InsertAfter
!                               (XmlAttribute newNode, XmlAttribute refNode)
!                       {
!                               if(newNode == null)
!                               {
!                                       throw new ArgumentException
!                                               (S._("Xml_NotSameDocument"), 
"node");
!                               }
!                               RemoveNamedItem(newNode.Name);
!                               if(refNode == null)
!                               {
!                                       map.Insert(0, newNode);
!                               }
!                               else
!                               {
!                                       map.Insert(GetItemPosition(refNode) + 
1, newNode);
!                               }
!                               return newNode;
!                       }
! 
!       // Insert a node before another one.
!       public virtual XmlAttribute InsertBefore
!                               (XmlAttribute newNode, XmlAttribute refNode)
!                       {
!                               if(newNode == null)
!                               {
!                                       throw new ArgumentException
!                                               (S._("Xml_NotSameDocument"), 
"node");
!                               }
!                               RemoveNamedItem(newNode.Name);
!                               if(refNode == null)
!                               {
!                                       map.Insert(Count, newNode);
!                               }
!                               else
!                               {
!                                       map.Insert(GetItemPosition(refNode), 
newNode);
!                               }
!                               return newNode;
!                       }
! 
!       // Prepend a node to this collection.
!       public virtual XmlAttribute Prepend(XmlAttribute node)
!                       {
!                               return InsertAfter(node, null);
!                       }
! 
!       // Remove an attribute from this collection.
!       public virtual XmlAttribute Remove(XmlAttribute node)
!                       {
!                               if(node == null)
!                               {
!                                       return null;
!                               }
!                               else
!                               {
!                                       return 
(XmlAttribute)(RemoveNamedItem(node.Name));
!                               }
!                       }
! 
!       // Remove all attributes from this collection.
!       public virtual void RemoveAll()
!                       {
!                               map.Clear();
!                       }
! 
!       // Remove the attribute at a particular index.
!       public virtual XmlAttribute RemoveAt(int i)
!                       {
!                               if(i < 0 || i >= map.Count)
!                               {
!                                       return null;
!                               }
!                               XmlAttribute attr = (XmlAttribute)(map[i]);
!                               map.RemoveAt(i);
!                               return attr;
!                       }
! 
!       // Set a named item into this node map, after making sure
!       // that it is indeed an attribute.
!       public override XmlNode SetNamedItem(XmlNode node)
!                       {
!                               if(node != null && !(node is XmlAttribute))
!                               {
!                                       throw new ArgumentException
!                                               
(S._("Xml_AttrCollectionWrongNode"), "node");
!                               }
!                               return SetOrAppend(node, false);
!                       }
! 
!       // Implement the ICollection interface.
!       void ICollection.CopyTo(Array array, int index)
!                       {
!                               int count = Count;
!                               int posn;
!                               for(posn = 0; posn < count; ++posn)
!                               {
!                                       array.SetValue(Item(posn), index);
!                                       ++index;
!                               }
!                       }
!       int ICollection.Count
!                       {
!                               get
!                               {
!                                       return Count;
!                               }
!                       }
!       bool ICollection.IsSynchronized
!                       {
!                               get
!                               {
!                                       return false;
!                               }
!                       }
!       Object ICollection.SyncRoot
!                       {
!                               get
!                               {
!                                       return this;
!                               }
!                       }
  
  }; // class XmlAttributeCollection

Index: XmlDocument.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlDocument.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** XmlDocument.cs      3 Dec 2002 07:28:06 -0000       1.2
--- XmlDocument.cs      4 Dec 2002 04:46:35 -0000       1.3
***************
*** 269,272 ****
--- 269,284 ----
                        }
  
+       // Create a CDATA section.
+       public virtual XmlCDataSection CreateCDataSection(String data)
+                       {
+                               return new XmlCDataSection(placeholder, data);
+                       }
+ 
+       // Create a comment node.
+       public virtual XmlComment CreateComment(String text)
+                       {
+                               return new XmlComment(placeholder, text);
+                       }
+ 
        // Create a document fragment that is attached to this node.
        public virtual XmlDocumentFragment CreateDocumentFragment()
***************
*** 275,283 ****
                        }
  
        // Create a text node.
!       public virtual XmlNode/*TODO:XmlText*/ CreateTextNode(String text)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 287,324 ----
                        }
  
+       // Create a document type that is attached to this node.
+       public virtual XmlDocumentType CreateDocumentType
+                               (String name, String publicId,
+                                String systemId, String internalSubset)
+                       {
+                               return new XmlDocumentType
+                                       (placeholder, name, publicId, systemId, 
internalSubset);
+                       }
+ 
+       // Create a significant whitespace node.
+       public virtual XmlSignificantWhitespace CreateSignificantWhitespace
+                               (String text)
+                       {
+                               return new 
XmlSignificantWhitespace(placeholder, text);
+                       }
+ 
        // Create a text node.
!       public virtual XmlText CreateTextNode(String text)
                        {
!                               return new XmlText(placeholder, text);
!                       }
! 
!       // Create a whitespace node.
!       public virtual XmlWhitespace CreateWhitespace(String text)
!                       {
!                               return new XmlWhitespace(placeholder, text);
!                       }
! 
!       // Create an XML declaration node.
!       public virtual XmlDeclaration CreateXmlDeclaration
!                               (String version, String encoding, String 
standalone)
!                       {
!                               return new XmlDeclaration
!                                       (placeholder, version, encoding, 
standalone);
                        }
  
***************
*** 303,306 ****
--- 344,441 ----
        public event XmlNodeChangedEventHandler NodeRemoved;
        public event XmlNodeChangedEventHandler NodeRemoving;
+ 
+       // Emit an event before a particular node change.  Returns an
+       // argument block if "EmitAfter" may be needed, or null if not.
+       internal XmlNodeChangedEventArgs EmitBefore
+                                       (XmlNodeChangedAction action, XmlNode 
node,
+                                        XmlNode oldParent, XmlNode newParent)
+                       {
+                               XmlNodeChangedEventArgs args = null;
+                               switch(action)
+                               {
+                                       case XmlNodeChangedAction.Insert:
+                                       {
+                                               if(NodeInserting != null)
+                                               {
+                                                       args = new 
XmlNodeChangedEventArgs
+                                                               (action, node, 
oldParent, newParent);
+                                                       NodeInserting(this, 
args);
+                                               }
+                                               else if(NodeInserted != null)
+                                               {
+                                                       args = new 
XmlNodeChangedEventArgs
+                                                               (action, node, 
oldParent, newParent);
+                                               }
+                                       }
+                                       break;
+ 
+                                       case XmlNodeChangedAction.Remove:
+                                       {
+                                               if(NodeRemoving != null)
+                                               {
+                                                       args = new 
XmlNodeChangedEventArgs
+                                                               (action, node, 
oldParent, newParent);
+                                                       NodeRemoving(this, 
args);
+                                               }
+                                               else if(NodeRemoved != null)
+                                               {
+                                                       args = new 
XmlNodeChangedEventArgs
+                                                               (action, node, 
oldParent, newParent);
+                                               }
+                                       }
+                                       break;
+ 
+                                       case XmlNodeChangedAction.Change:
+                                       {
+                                               if(NodeChanging != null)
+                                               {
+                                                       args = new 
XmlNodeChangedEventArgs
+                                                               (action, node, 
oldParent, newParent);
+                                                       NodeChanging(this, 
args);
+                                               }
+                                               else if(NodeChanged != null)
+                                               {
+                                                       args = new 
XmlNodeChangedEventArgs
+                                                               (action, node, 
oldParent, newParent);
+                                               }
+                                       }
+                                       break;
+                               }
+                               return args;
+                       }
+ 
+       // Emit an event after a particular node change.
+       internal new void EmitAfter(XmlNodeChangedEventArgs args)
+                       {
+                               switch(args.Action)
+                               {
+                                       case XmlNodeChangedAction.Insert:
+                                       {
+                                               if(NodeInserted != null)
+                                               {
+                                                       NodeInserted(this, 
args);
+                                               }
+                                       }
+                                       break;
+ 
+                                       case XmlNodeChangedAction.Remove:
+                                       {
+                                               if(NodeRemoved != null)
+                                               {
+                                                       NodeRemoved(this, args);
+                                               }
+                                       }
+                                       break;
+ 
+                                       case XmlNodeChangedAction.Change:
+                                       {
+                                               if(NodeChanged != null)
+                                               {
+                                                       NodeChanged(this, args);
+                                               }
+                                       }
+                                       break;
+                               }
+                       }
  
  }; // class XmlDocument

Index: XmlDocumentType.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlDocumentType.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** XmlDocumentType.cs  3 Dec 2002 07:28:06 -0000       1.1
--- XmlDocumentType.cs  4 Dec 2002 04:46:35 -0000       1.2
***************
*** 30,37 ****
  public
  #endif
! abstract class XmlDocumentType : XmlNode
  {
!       // TODO
!       public XmlDocumentType() : base(null) {}
  
  }; // class XmlDocumentType
--- 30,161 ----
  public
  #endif
! class XmlDocumentType : XmlLinkedNode
  {
!       // Internal state.
!       private String name;
!       private String publicId;
!       private String systemId;
!       private String internalSubset;
!       private XmlNamedNodeMap entities;
!       private XmlNamedNodeMap notations;
! 
!       // Constructor.
!       internal XmlDocumentType(XmlNode parent, String name, String publicId,
!                                                        String systemId, 
String internalSubset)
!                       : base(parent)
!                       {
!                               XmlNameTable nt = 
parent.FindOwnerQuick().NameTable;
!                               this.name =
!                                       ((name != null) ? nt.Add(name) : 
String.Empty);
!                               this.publicId =
!                                       ((publicId != null) ? nt.Add(publicId) 
: String.Empty);
!                               this.systemId =
!                                       ((systemId != null) ? nt.Add(systemId) 
: String.Empty);
!                               this.internalSubset =
!                                       ((internalSubset != null) ? 
nt.Add(internalSubset)
!                                                                               
          : String.Empty);
!                               entities = new XmlNamedNodeMap(this);
!                               notations = new XmlNamedNodeMap(this);
!                       }
! 
!       // Get the entity list for this document type.
!       public XmlNamedNodeMap Entities
!                       {
!                               get
!                               {
!                                       return entities;
!                               }
!                       }
! 
!       // Get the internal subset information for this document type.
!       public String InternalSubset
!                       {
!                               get
!                               {
!                                       return internalSubset;
!                               }
!                       }
! 
!       // Determine if this node is read-only.
!       public override bool IsReadOnly
!                       {
!                               get
!                               {
!                                       return true;
!                               }
!                       }
! 
!       // Get the local name of the document type.
!       public override String LocalName
!                       {
!                               get
!                               {
!                                       return name;
!                               }
!                       }
! 
!       // Get the qualified name of the document type.
!       public override String Name
!                       {
!                               get
!                               {
!                                       return name;
!                               }
!                       }
! 
!       // Get the type of this node.
!       public override XmlNodeType NodeType
!                       {
!                               get
!                               {
!                                       return XmlNodeType.DocumentType;
!                               }
!                       }
! 
!       // Get the notation list for this document type.
!       public XmlNamedNodeMap Notations
!                       {
!                               get
!                               {
!                                       return notations;
!                               }
!                       }
! 
!       // Get the public identifier for this document type.
!       public String PublicId
!                       {
!                               get
!                               {
!                                       return publicId;
!                               }
!                       }
! 
!       // Get the system identifier for this document type.
!       public String SystemId
!                       {
!                               get
!                               {
!                                       return systemId;
!                               }
!                       }
! 
!       // Clone this node.
!       public override XmlNode CloneNode(bool deep)
!                       {
!                               return OwnerDocument.CreateDocumentType
!                                       (name, publicId, systemId, 
internalSubset);
!                       }
! 
!       // Writes the contents of this node to a specified XmlWriter.
!       public override void WriteContentTo(XmlWriter w)
!                       {
!                               // Nothing needs to be done here for DTD nodes.
!                       }
! 
!       // Write this node and all of its contents to a specified XmlWriter.
!       public override void WriteTo(XmlWriter w)
!                       {
!                               w.WriteDocType(name, publicId, systemId, 
internalSubset);
!                       }
  
  }; // class XmlDocumentType

Index: XmlElement.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlElement.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** XmlElement.cs       27 Jul 2002 09:42:59 -0000      1.1
--- XmlElement.cs       4 Dec 2002 04:46:35 -0000       1.2
***************
*** 57,61 ****
                                        prefix = String.Empty;
                                }
!                               this.attributes = new XmlAttributeCollection();
                                this.isEmpty = true;
                        }
--- 57,61 ----
                                        prefix = String.Empty;
                                }
!                               this.attributes = new 
XmlAttributeCollection(this);
                                this.isEmpty = true;
                        }

Index: XmlNode.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlNode.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** XmlNode.cs  3 Dec 2002 07:28:06 -0000       1.8
--- XmlNode.cs  4 Dec 2002 04:46:35 -0000       1.9
***************
*** 610,613 ****
--- 610,666 ----
                        }
  
+       // Quickly find the document that owns a node, without recursion.
+       internal XmlDocument FindOwnerQuick()
+                       {
+                               XmlNode node = this;
+                               while(node != null)
+                               {
+                                       if(node is XmlDocument)
+                                       {
+                                               return (XmlDocument)node;
+                                       }
+                                       node = node.parent;
+                               }
+                               return null;
+                       }
+ 
+       // Emit an event just before a change.  Returns an argument
+       // block if an after event will also need to be emitted.
+       internal XmlNodeChangedEventArgs EmitBefore
+                               (XmlNodeChangedAction action,
+                            XmlNode oldParent, XmlNode newParent)
+                       {
+                               XmlDocument doc = FindOwnerQuick();
+                               if(doc != null)
+                               {
+                                       return doc.EmitBefore(action, this, 
oldParent, newParent);
+                               }
+                               else
+                               {
+                                       return null;
+                               }
+                       }
+       internal XmlNodeChangedEventArgs EmitBefore(XmlNodeChangedAction action)
+                       {
+                               XmlDocument doc = FindOwnerQuick();
+                               if(doc != null)
+                               {
+                                       return doc.EmitBefore(action, this, 
parent, parent);
+                               }
+                               else
+                               {
+                                       return null;
+                               }
+                       }
+ 
+       // Emit an event just after a change.
+       internal void EmitAfter(XmlNodeChangedEventArgs args)
+                       {
+                               if(args != null)
+                               {
+                                       FindOwnerQuick().EmitAfter(args);
+                               }
+                       }
+ 
  }; // class XmlNode
  





reply via email to

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