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 NameCache.cs,NONE,1.1 XmlD


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Xml NameCache.cs,NONE,1.1 XmlDocumentFragment.cs,NONE,1.1 XmlDocumentType.cs,NONE,1.1 XmlImplementation.cs,NONE,1.1 XmlNodeChangedAction.cs,NONE,1.1 XmlNodeChangedEventArgs.cs,NONE,1.1 XmlNodeChangedEventHandler.cs,NONE,1.1 Xml.build,1.5,1.6 XmlAttribute.cs,1.2,1.3 XmlDocument.cs,1.1,1.2 XmlNode.cs,1.7,1.8
Date: Tue, 03 Dec 2002 02:28:08 -0500

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

Modified Files:
        Xml.build XmlAttribute.cs XmlDocument.cs XmlNode.cs 
Added Files:
        NameCache.cs XmlDocumentFragment.cs XmlDocumentType.cs 
        XmlImplementation.cs XmlNodeChangedAction.cs 
        XmlNodeChangedEventArgs.cs XmlNodeChangedEventHandler.cs 
Log Message:


Continue implementing System.Xml.


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

// The name cache keeps track of "prefix, localname, namespaceURI"
// tuples so that there is only one of each tuple in a document.
// This can substantially reduce the memory requirements.

internal sealed class NameCache : Hashtable
{
        // Internal state.
        private XmlNameTable nameTable;

        // Constructor.
        public NameCache(XmlNameTable nt) : base()
                        {
                                nameTable = nt;
                        }

        // Add an entry to the name cache.
        public NameInfo Add(String localName, String prefix, String ns)
                        {
                                // Intern the strings into the name table.
                                String name;
                                if(localName != null)
                                {
                                        localName = nameTable.Add(localName);
                                }
                                else
                                {
                                        localName = String.Empty;
                                }
                                if(prefix != null)
                                {
                                        prefix = nameTable.Add(prefix);
                                }
                                else
                                {
                                        prefix = String.Empty;
                                }
                                if(ns != null)
                                {
                                        ns = nameTable.Add(prefix);
                                }
                                else
                                {
                                        ns = String.Empty;
                                }
                                if(prefix.Length > 0)
                                {
                                        name = nameTable.Add(prefix + ":" + 
localName);
                                }
                                else
                                {
                                        name = localName;
                                }

                                // Search for an existing entry with this name.
                                NameInfo info = (NameInfo)(this[localName]);
                                NameInfo first = info;
                                while(info != null)
                                {
                                        if(((Object)(info.localName)) == 
((Object)localName) &&
                                           ((Object)(info.prefix)) == 
((Object)prefix) &&
                                           ((Object)(info.ns)) == ((Object)ns))
                                        {
                                                return info;
                                        }
                                        info = info.next;
                                }

                                // Add a new entry to the hash table.
                                info = new NameInfo(localName, prefix, name, 
ns, first);
                                this[localName] = info;
                                return info;
                        }

        // Short-cut the hash table so that it compares keys much more quickly.
        protected override bool KeyEquals(Object item, Object key)
                        {
                                return (item == key);
                        }
        protected override int GetHash(Object key)
                        {
                                return key.GetHashCode();
                        }

        // Name information.
        public sealed class NameInfo
        {
                // Internal state.
                public String localName;
                public String prefix;
                public String name;
                public String ns;
                public NameInfo next;

                // Constructor.
                public NameInfo(String localName, String prefix,
                                                String name, String ns, 
NameInfo next)
                        {
                                this.localName = localName;
                                this.prefix = prefix;
                                this.name = name;
                                this.ns = ns;
                                this.next = next;
                        }

        }; // class NameInfo

}; // class NameCache

}; // namespace System.Xml

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

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlDocumentFragment : XmlNode
{
        // Internal state.
        private XmlDocument document;

        // Constructors.
        internal XmlDocumentFragment(XmlDocument doc) : base(doc)
                        {
                                document = doc;
                        }

        // Get the markup that represents the children of this node.
        public override String InnerXml
                        {
                                get
                                {
                                        // TODO
                                        return null;
                                }
                                set
                                {
                                        // TODO
                                }
                        }

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

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

        // Get the type of this node.
        public override XmlNodeType NodeType
                        {
                                get
                                {
                                        return XmlNodeType.DocumentFragment;
                                }
                        }

        // Get the document that owns this node.
        public override XmlDocument OwnerDocument
                        {
                                get
                                {
                                        return document;
                                }
                        }

        // Get the parent of this node.
        public override XmlNode ParentNode
                        {
                                get
                                {
                                        return null;
                                }
                        }

        // Determine if this node is a placeholder fragment for nodes that have
        // not yet been added to the main document.
        internal override bool IsPlaceholder
                        {
                                get
                                {
                                        return (document.placeholder == this);
                                }
                        }

        // Clone this document fragment node.
        public override XmlNode CloneNode(bool deep)
                        {
                                XmlDocumentFragment frag =
                                        document.CreateDocumentFragment();
                                frag.CloneChildrenFrom(this, deep);
                                return frag;
                        }

        // Write the contents of this document to an XML writer.
        [TODO]
        public override void WriteContentTo(XmlWriter xw)
                        {
                                // TODO
                        }

        // Write this document to an XML writer.
        [TODO]
        public override void WriteTo(XmlWriter w)
                        {
                                // TODO
                        }

}; // class XmlDocumentFragment

}; // namespace System.Xml

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

#if ECMA_COMPAT
internal
#else
public
#endif
abstract class XmlDocumentType : XmlNode
{
        // TODO
        public XmlDocumentType() : base(null) {}

}; // class XmlDocumentType

}; // namespace System.Xml

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

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlImplementation
{
        // Internal state.
        internal XmlNameTable nameTable;

        // Constructor.
        public XmlImplementation()
                        {
                                nameTable = new NameTable();
                        }
        internal XmlImplementation(XmlNameTable nt)
                        {
                                nameTable = nt;
                        }

        // Create a new document.
        public virtual XmlDocument CreateDocument()
                        {
                                return new XmlDocument(this);
                        }

        // Determine if this implementation has a specific feature.
        public bool HasFeature(String strFeature, String strVersion)
                        {
                                if(String.Compare(strFeature, "XML",
                                                                  true, 
CultureInfo.InvariantCulture) == 0 &&
                                   (strVersion == "1.0" || strVersion == "2.0"))
                                {
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }
                        }

}; // class XmlImplementation

}; // namespace System.Xml

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

#if ECMA_COMPAT
internal
#else
[Serializable]
public
#endif
enum XmlNodeChangedAction
{
        Insert = 0,
        Remove = 1,
        Change = 2

}; // enum XmlNodeChangedAction

}; // namespace System.Xml

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

#if ECMA_COMPAT
internal
#else
public
#endif
class XmlNodeChangedEventArgs
{
        // Internal state.
        private XmlNodeChangedAction action;
        private XmlNode node;
        private XmlNode oldParent;
        private XmlNode newParent;

        // Constructor.
        internal XmlNodeChangedEventArgs
                                (XmlNodeChangedAction action, XmlNode node,
                                 XmlNode oldParent, XmlNode newParent)
                        {
                                this.action = action;
                                this.node = node;
                                this.oldParent = oldParent;
                                this.newParent = newParent;
                        }

        // Properties.
        public XmlNodeChangedAction Action
                        {
                                get
                                {
                                        return action;
                                }
                        }
        public XmlNode Node
                        {
                                get
                                {
                                        return node;
                                }
                        }
        public XmlNode OldParent
                        {
                                get
                                {
                                        return oldParent;
                                }
                        }
        public XmlNode NewParent
                        {
                                get
                                {
                                        return newParent;
                                }
                        }

}; // class XmlNodeChangedEventArgs

}; // namespace System.Xml

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

#if ECMA_COMPAT
internal
#else
[Serializable]
public
#endif
delegate void XmlNodeChangedEventHandler
                (Object sender, XmlNodeChangedEventArgs e);

}; // namespace System.Xml

Index: Xml.build
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/Xml.build,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Xml.build   2 Dec 2002 23:55:43 -0000       1.5
--- Xml.build   3 Dec 2002 07:28:06 -0000       1.6
***************
*** 30,33 ****
--- 30,34 ----
                        <arg compiler="csc" value="/nowarn:67"/>
                        <arg compiler="csc" value="/nowarn:169"/>
+                       <arg compiler="csc" value="/nowarn:679"/>
                </compile>
  

Index: XmlAttribute.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlAttribute.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** XmlAttribute.cs     3 Dec 2002 03:48:29 -0000       1.2
--- XmlAttribute.cs     3 Dec 2002 07:28:06 -0000       1.3
***************
*** 33,62 ****
  {
        // Internal state.
!       private String prefix;
!       private String localName;
!       private String ns;
!       private String name;
        internal char quoteChar;
        internal XmlAttribute next;
  
        // Constructor.
!       internal XmlAttribute(XmlNode owner, String prefix,
!                                                 String localName, String ns)
!                       : base(owner)
                        {
!                               this.prefix = prefix;
!                               this.localName =
!                                       ((localName != null) ? localName : 
String.Empty);
!                               this.ns = ((ns != null) ? ns : String.Empty);
!                               if(prefix != null)
!                               {
!                                       name = prefix + ":" + localName;
!                               }
!                               else
!                               {
!                                       name = localName;
!                                       prefix = String.Empty;
!                               }
!                               quoteChar = '"';
                        }
  
--- 33,47 ----
  {
        // Internal state.
!       private NameCache.NameInfo name;
        internal char quoteChar;
        internal XmlAttribute next;
  
        // Constructor.
!       internal XmlAttribute(XmlNode parent, NameCache.NameInfo name)
!                       : base(parent)
                        {
!                               this.name = name;
!                               this.quoteChar = '"';
!                               this.next = null;
                        }
  
***************
*** 80,89 ****
  
        // Get the inner text version of this node.
        public override String InnerText
                        {
                                get
                                {
                                        // TODO
!                                       return null;
                                }
                                set
--- 65,88 ----
  
        // Get the inner text version of this node.
+       [TODO]
        public override String InnerText
                        {
                                get
                                {
+                                       return base.InnerText;
+                               }
+                               set
+                               {
                                        // TODO
!                               }
!                       }
! 
!       // Get the inner XML version of this node.
!       [TODO]
!       public override String InnerXml
!                       {
!                               get
!                               {
!                                       return base.InnerXml;
                                }
                                set
***************
*** 98,102 ****
                                get
                                {
!                                       return localName;
                                }
                        }
--- 97,101 ----
                                get
                                {
!                                       return name.localName;
                                }
                        }
***************
*** 107,111 ****
                                get
                                {
!                                       return name;
                                }
                        }
--- 106,110 ----
                                get
                                {
!                                       return name.name;
                                }
                        }
***************
*** 116,120 ****
                                get
                                {
!                                       return ns;
                                }
                        }
--- 115,119 ----
                                get
                                {
!                                       return name.ns;
                                }
                        }
***************
*** 169,173 ****
                                get
                                {
!                                       return prefix;
                                }
                        }
--- 168,172 ----
                                get
                                {
!                                       return name.prefix;
                                }
                        }

Index: XmlDocument.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlDocument.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** XmlDocument.cs      27 Jul 2002 09:42:59 -0000      1.1
--- XmlDocument.cs      3 Dec 2002 07:28:06 -0000       1.2
***************
*** 32,71 ****
  {
        // Internal state.
!       private String prefix;
!       private String localName;
!       private String ns;
!       private String name;
! 
!       // Constructor.
!       internal XmlDocument(XmlNode owner, String prefix,
!                                           String localName, String ns)
!                       : base(owner)
!                       {
!                               this.prefix = prefix;
!                               this.localName =
!                                       ((localName != null) ? localName : 
String.Empty);
!                               this.ns = ((ns != null) ? ns : String.Empty);
!                               if(prefix != null)
                                {
!                                       name = prefix + ":" + localName;
                                }
                                else
                                {
!                                       name = localName;
!                                       prefix = String.Empty;
                                }
                        }
  
!       // Get the base URI for this document.
        public override String BaseURI
                        {
                                get
                                {
!                                       return parent.BaseURI;
                                }
                        }
  
!       // Get the inner text version of this node.
!       public override String InnerText
                        {
                                get
--- 32,125 ----
  {
        // Internal state.
!       private XmlImplementation implementation;
!       private String baseURI;
!       private XmlElement root;
!       private XmlDocumentType docType;
!       private bool preserveWhitespace;
!       private XmlResolver xmlResolver;
!       private NameCache nameCache;
!       internal XmlDocumentFragment placeholder;
!       internal static readonly String xmlns = "http://www.w3.org/2000/xmlns/";;
! 
!       // Constructors.
!       public XmlDocument() : base(null)
!                       {
!                               implementation = new XmlImplementation();
!                               Initialize();
!                       }
!       protected internal XmlDocument(XmlImplementation imp) : base(null)
!                       {
!                               if(imp != null)
!                               {
!                                       implementation = imp;
!                               }
!                               else
!                               {
!                                       implementation = new 
XmlImplementation();
!                               }
!                               Initialize();
!                       }
!       public XmlDocument(XmlNameTable nt) : base(null)
!                       {
!                               if(nt != null)
                                {
!                                       implementation = new 
XmlImplementation(nt);
                                }
                                else
                                {
!                                       implementation = new 
XmlImplementation();
                                }
+                               Initialize();
                        }
  
!       // Initialize the document.
!       private void Initialize()
!                       {
!                               baseURI = String.Empty;
!                               root = null;
!                               docType = null;
!                               preserveWhitespace = false;
!                               placeholder = new XmlDocumentFragment(this);
!                               nameCache = new 
NameCache(implementation.nameTable);
!                       }
! 
!       // Get the base URI for the document.
        public override String BaseURI
                        {
                                get
                                {
!                                       return baseURI;
!                               }
!                       }
! 
!       // Get the root element for the document.
!       public XmlElement DocumentElement
!                       {
!                               get
!                               {
!                                       return root;
!                               }
!                       }
! 
!       // Get the document type declaration.
!       public virtual XmlDocumentType DocumentType
!                       {
!                               get
!                               {
!                                       return docType;
!                               }
!                       }
! 
!       // Get the implementation associated with this document.
!       public XmlImplementation Implementation
!                       {
!                               get
!                               {
!                                       return implementation;
                                }
                        }
  
!       // Get the markup that represents the children of this node.
!       public override String InnerXml
                        {
                                get
***************
*** 80,116 ****
                        }
  
!       // Get the local name associated with this node.
        public override String LocalName
                        {
                                get
                                {
!                                       return localName;
                                }
                        }
  
!       // Get the name associated with this node.
        public override String Name
                        {
                                get
                                {
!                                       return name;
                                }
                        }
  
!       // Get the namespace URI associated with this node.
!       public override String NamespaceURI
                        {
                                get
                                {
!                                       return ns;
                                }
                        }
  
!       // Get the type that is associated with this node.
        public override XmlNodeType NodeType
                        {
                                get
                                {
!                                       return XmlNodeType.Attribute;
                                }
                        }
--- 134,179 ----
                        }
  
!       // Determine if this document is read-only.
!       public override bool IsReadOnly
!                       {
!                               get
!                               {
!                                       return false;
!                               }
!                       }
! 
!       // Get the local name of this node.
        public override String LocalName
                        {
                                get
                                {
!                                       return "#document";
                                }
                        }
  
!       // Get the name of this node.
        public override String Name
                        {
                                get
                                {
!                                       return "#document";
                                }
                        }
  
!       // Get the name table associated with this document.
!       public XmlNameTable NameTable
                        {
                                get
                                {
!                                       return implementation.nameTable;
                                }
                        }
  
!       // Get the type of this node.
        public override XmlNodeType NodeType
                        {
                                get
                                {
!                                       return XmlNodeType.Document;
                                }
                        }
***************
*** 121,188 ****
                                get
                                {
!                                       XmlElement owner = OwnerElement;
!                                       if(owner != null)
!                                       {
!                                               return owner.OwnerDocument;
!                                       }
!                                       else
!                                       {
!                                               return null;
!                                       }
                                }
                        }
  
!       // Get the element that owns this attribute.
!       public virtual XmlElement OwnerElement
                        {
                                get
                                {
!                                       return (XmlElement)parent;
                                }
                        }
  
!       // Get the parent of this node.
!       public override XmlNode ParentNode
                        {
!                               get
                                {
!                                       return OwnerElement;
                                }
                        }
  
!       // Get the prefix associated with this node.
!       public override String Prefix
                        {
!                               get
!                               {
!                                       return prefix;
!                               }
                        }
  
!       // Determine if the attribute value was explictly specified.
!       public virtual bool Specified
                        {
!                               get
                                {
!                                       // TODO
!                                       return true;
                                }
                        }
! 
!       // Get or set the value associated with this node.
!       public override String Value
                        {
!                               get
                                {
!                                       return null;
                                }
!                               set
                                {
!                                       // TODO
                                }
                        }
  
!       // Clone this node in either shallow or deep mode.
!       public override XmlNode CloneNode(bool deep)
                        {
                                // TODO
--- 184,280 ----
                                get
                                {
!                                       return null;
                                }
                        }
  
!       // Get or set the whitespace preservation flag.
!       public bool PreserveWhitespace
                        {
                                get
                                {
!                                       return preserveWhitespace;
!                               }
!                               set
!                               {
!                                       preserveWhitespace = value;
                                }
                        }
  
!       // Set the resolver to use for external resources.
!       public XmlResolver XmlResolver
                        {
!                               set
                                {
!                                       xmlResolver = value;
                                }
                        }
  
!       // Clone this document node.
!       [TODO]
!       public override XmlNode CloneNode(bool deep)
                        {
!                               // TODO
!                               return null;
                        }
  
!       // Create an attribute and associate it with this document.
!       public XmlAttribute CreateAttribute(String name)
                        {
!                               int colon = name.LastIndexOf(':');
!                               if(colon == -1)
                                {
!                                       return CreateAttribute(name, 
String.Empty, String.Empty);
!                               }
!                               else
!                               {
!                                       String prefix = name.Substring(0, 
colon);
!                                       String localName = name.Substring(colon 
+ 1);
!                                       if(prefix == "xmlns")
!                                       {
!                                               return 
CreateAttribute(localName, prefix, xmlns);
!                                       }
!                                       else
!                                       {
!                                               return 
CreateAttribute(localName, prefix, String.Empty);
!                                       }
                                }
                        }
!       public XmlAttribute CreateAttribute(String qualifiedName,
!                                                                               
String namespaceURI)
                        {
!                               int colon = qualifiedName.LastIndexOf(':');
!                               if(colon == -1)
                                {
!                                       return CreateAttribute
!                                               (qualifiedName, String.Empty, 
namespaceURI);
                                }
!                               else
                                {
!                                       String prefix = 
qualifiedName.Substring(0, colon);
!                                       String localName = 
qualifiedName.Substring(colon + 1);
!                                       return CreateAttribute(localName, 
prefix, namespaceURI);
                                }
                        }
+       public virtual XmlAttribute CreateAttribute
+                               (String localName, String prefix, String 
namespaceURI)
+                       {
+                               if(prefix == "xmlns" && namespaceURI != xmlns)
+                               {
+                                       throw new ArgumentException
+                                               
(S._("Xml_InvalidNamespaceURI"), "namespaceURI");
+                               }
+                               NameCache.NameInfo info =
+                                       nameCache.Add(localName, prefix, 
namespaceURI);
+                               return new XmlAttribute(placeholder, info);
+                       }
  
!       // Create a document fragment that is attached to this node.
!       public virtual XmlDocumentFragment CreateDocumentFragment()
!                       {
!                               return new XmlDocumentFragment(this);
!                       }
! 
!       // Create a text node.
!       public virtual XmlNode/*TODO:XmlText*/ CreateTextNode(String text)
                        {
                                // TODO
***************
*** 190,204 ****
                        }
  
!       // Writes the contents of this node to a specified XmlWriter.
!       public override void WriteContentTo(XmlWriter w)
                        {
                                // TODO
                        }
  
!       // Write this node and all of its contents to a specified XmlWriter.
        public override void WriteTo(XmlWriter w)
                        {
                                // TODO
                        }
  
  }; // class XmlDocument
--- 282,306 ----
                        }
  
!       // Write the contents of this document to an XML writer.
!       [TODO]
!       public override void WriteContentTo(XmlWriter xw)
                        {
                                // TODO
                        }
  
!       // Write this document to an XML writer.
!       [TODO]
        public override void WriteTo(XmlWriter w)
                        {
                                // TODO
                        }
+ 
+       // Events.
+       public event XmlNodeChangedEventHandler NodeChanged;
+       public event XmlNodeChangedEventHandler NodeChanging;
+       public event XmlNodeChangedEventHandler NodeInserted;
+       public event XmlNodeChangedEventHandler NodeInserting;
+       public event XmlNodeChangedEventHandler NodeRemoved;
+       public event XmlNodeChangedEventHandler NodeRemoving;
  
  }; // class XmlDocument

Index: XmlNode.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System.Xml/XmlNode.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** XmlNode.cs  3 Dec 2002 03:48:29 -0000       1.7
--- XmlNode.cs  3 Dec 2002 07:28:06 -0000       1.8
***************
*** 24,27 ****
--- 24,28 ----
  using System;
  using System.Collections;
+ using System.Text;
  using System.Xml.XPath;
  
***************
*** 88,91 ****
--- 89,101 ----
                        }
  
+       // Determine if this node type can contain child nodes.
+       internal virtual bool CanHaveChildren
+                       {
+                               get
+                               {
+                                       return false;
+                               }
+                       }
+ 
        // Get the children of this node.
        public virtual XmlNodeList ChildNodes
***************
*** 115,118 ****
--- 125,158 ----
                        }
  
+       // Collect the inner text versions of a node and all of its children.
+       private void CollectInner(StringBuilder builder)
+                       {
+                               XmlNode current = NodeList.GetFirstChild(this);
+                               while(current != null)
+                               {
+                                       if(NodeList.GetFirstChild(current) == 
null)
+                                       {
+                                               switch(current.NodeType)
+                                               {
+                                                       case XmlNodeType.Text:
+                                                       case XmlNodeType.CDATA:
+                                                       case 
XmlNodeType.SignificantWhitespace:
+                                                       case 
XmlNodeType.Whitespace:
+                                                       {
+                                                               
builder.Append(current.InnerText);
+                                                       }
+                                                       break;
+ 
+                                                       default: break;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               current.CollectInner(builder);
+                                       }
+                                       current = NodeList.GetNextSibling(this);
+                               }
+                       }
+ 
        // Get the inner text version of this node.
        public virtual String InnerText
***************
*** 120,129 ****
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                                set
                                {
!                                       // TODO
                                }
                        }
--- 160,214 ----
                                get
                                {
!                                       XmlNode child = 
NodeList.GetFirstChild(this);
!                                       XmlNode next;
!                                       if(child == null)
!                                       {
!                                               return String.Empty;
!                                       }
!                                       next = NodeList.GetNextSibling(child);
!                                       if(next == null)
!                                       {
!                                               // Special-case the case of a 
single text child.
!                                               switch(child.NodeType)
!                                               {
!                                                       case XmlNodeType.Text:
!                                                       case XmlNodeType.CDATA:
!                                                       case 
XmlNodeType.SignificantWhitespace:
!                                                       case 
XmlNodeType.Whitespace:
!                                                       {
!                                                               return 
child.Value;
!                                                       }
!                                                       // Not reached
! 
!                                                       default: break;
!                                               }
!                                       }
!                                       StringBuilder builder = new 
StringBuilder();
!                                       CollectInner(builder);
!                                       return builder.ToString();
                                }
                                set
                                {
!                                       XmlNode child = 
NodeList.GetFirstChild(this);
!                                       if(child != null && 
NodeList.GetNextSibling(child) == null)
!                                       {
!                                               // Special-case the case of a 
single text child.
!                                               switch(child.NodeType)
!                                               {
!                                                       case XmlNodeType.Text:
!                                                       case XmlNodeType.CDATA:
!                                                       case 
XmlNodeType.SignificantWhitespace:
!                                                       case 
XmlNodeType.Whitespace:
!                                                       {
!                                                               child.Value = 
value;
!                                                               return;
!                                                       }
!                                                       // Not reached
! 
!                                                       default: break;
!                                               }
!                                       }
!                                       RemoveAll();
!                                       
AppendChild(OwnerDocument.CreateTextNode(value));
                                }
                        }
***************
*** 139,143 ****
                                set
                                {
!                                       // TODO
                                }
                        }
--- 224,229 ----
                                set
                                {
!                                       throw new InvalidOperationException
!                                               (S._("Xml_CannotSetInnerXml"));
                                }
                        }
***************
*** 148,153 ****
                                get
                                {
!                                       // TODO
!                                       return false;
                                }
                        }
--- 234,245 ----
                                get
                                {
!                                       if(parent != null)
!                                       {
!                                               return parent.IsReadOnly;
!                                       }
!                                       else
!                                       {
!                                               return false;
!                                       }
                                }
                        }
***************
*** 251,256 ****
                                get
                                {
!                                       // TODO
!                                       return null;
                                }
                        }
--- 343,361 ----
                                get
                                {
!                                       if(parent != null)
!                                       {
!                                               if(parent is XmlDocument)
!                                               {
!                                                       return 
(XmlDocument)parent;
!                                               }
!                                               else
!                                               {
!                                                       return 
parent.OwnerDocument;
!                                               }
!                                       }
!                                       else
!                                       {
!                                               return null;
!                                       }
                                }
                        }
***************
*** 261,265 ****
                                get
                                {
!                                       return parent;
                                }
                        }
--- 366,377 ----
                                get
                                {
!                                       if(parent != null && 
!parent.IsPlaceholder)
!                                       {
!                                               return parent;
!                                       }
!                                       else
!                                       {
!                                               return null;
!                                       }
                                }
                        }
***************
*** 292,297 ****
                                set
                                {
!                                       // TODO
                                }
                        }
  
--- 404,424 ----
                                set
                                {
!                                       throw new InvalidOperationException
!                                               (S._("Xml_CannotSetValue"));
!                               }
!                       }
! 
!       // Determine if one node is an ancestor of another.
!       private static bool IsAncestorOf(XmlNode node1, XmlNode node2)
!                       {
!                               while(node2 != null)
!                               {
!                                       if(node2 == node1)
!                                       {
!                                               return true;
!                                       }
!                                       node2 = node2.parent;
                                }
+                               return false;
                        }
  
***************
*** 299,303 ****
        public virtual XmlNode AppendChild(XmlNode newChild)
                        {
!                               // TODO
                                return newChild;
                        }
--- 426,457 ----
        public virtual XmlNode AppendChild(XmlNode newChild)
                        {
!                               XmlDocument doc;
!                               if(!CanHaveChildren)
!                               {
!                                       throw new InvalidOperationException
!                                               (S._("Xml_CannotHaveChildren"));
!                               }
!                               if(IsAncestorOf(newChild, this))
!                               {
!                                       throw new 
InvalidOperationException(S._("Xml_IsAncestor"));
!                               }
!                               if(this is XmlDocument)
!                               {
!                                       doc = (XmlDocument)this;
!                               }
!                               else
!                               {
!                                       doc = OwnerDocument;
!                               }
!                               if(newChild.OwnerDocument != doc)
!                               {
!                                       throw new ArgumentException
!                                               (S._("Xml_NotSameDocument"), 
"newChild");
!                               }
!                               if(IsReadOnly)
!                               {
!                                       throw new 
ArgumentException(S._("Xml_ReadOnly"));
!                               }
!                               // TODO: remove from original position and add 
to the new.
                                return newChild;
                        }
***************
*** 439,442 ****
--- 593,612 ----
        // Write this node and all of its contents to a specified XmlWriter.
        public abstract void WriteTo(XmlWriter w);
+ 
+       // Clone the children from another node into this node.
+       internal void CloneChildrenFrom(XmlNode other, bool deep)
+                       {
+                               // TODO
+                       }
+ 
+       // Determine if this node is a placeholder fragment for nodes that have
+       // not yet been added to the main document.
+       internal virtual bool IsPlaceholder
+                       {
+                               get
+                               {
+                                       return false;
+                               }
+                       }
  
  }; // class XmlNode





reply via email to

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