Author: atsushi
Date: 2005-02-25 04:39:56 -0500 (Fri, 25 Feb 2005)
New Revision: 41185

Modified:
   trunk/mcs/class/System.XML/System.Xml/ChangeLog
   trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs
   trunk/mcs/class/System.XML/System.Xml/XmlCDataSection.cs
   trunk/mcs/class/System.XML/System.Xml/XmlComment.cs
   trunk/mcs/class/System.XML/System.Xml/XmlElement.cs
   trunk/mcs/class/System.XML/System.Xml/XmlEntity.cs
   trunk/mcs/class/System.XML/System.Xml/XmlEntityReference.cs
   trunk/mcs/class/System.XML/System.Xml/XmlNode.cs
   trunk/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs
   trunk/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs
   trunk/mcs/class/System.XML/System.Xml/XmlText.cs
   trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
   trunk/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs
Log:
2005-02-25  Atsushi Enomoto <[EMAIL PROTECTED]>

        * XmlComment.cs, XmlNode.cs, XmlText.cs, XmlProcessingInstruction.cs,
          XmlEntityReference.cs, XmlSignificantWhitespace.cs, XmlAttribute.cs,
          XmlElement.cs, XmlEntity.cs, XmlCDataSection.cs :
          For those nodes that are created by Clone(), IsReadOnly is false.
          Patch by Konstantin Triger.

        * XmlNodeTests.cs : added Clone() of readonly node returns a node
          that is not readonly.




Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog     2005-02-25 07:40:58 UTC 
(rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog     2005-02-25 09:39:56 UTC 
(rev 41185)
@@ -1,7 +1,15 @@
 2005-02-25  Atsushi Enomoto <[EMAIL PROTECTED]>
 
+       * XmlComment.cs, XmlNode.cs, XmlText.cs, XmlProcessingInstruction.cs,
+         XmlEntityReference.cs, XmlSignificantWhitespace.cs, XmlAttribute.cs,
+         XmlElement.cs, XmlEntity.cs, XmlCDataSection.cs :
+         For those nodes that are created by Clone(), IsReadOnly is false.
+         Patch by Konstantin Triger.
+
+2005-02-25  Atsushi Enomoto <[EMAIL PROTECTED]>
+
        * XmlDocumentNavigator.cs : iteratedNames array could be fixed and
-         performance got improved. Patch by Knstantin Triger.
+         performance got improved. Patch by Konstantin Triger.
 
 2005-02-25  Atsushi Enomoto <[EMAIL PROTECTED]>
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs       2005-02-25 
07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs       2005-02-25 
09:39:56 UTC (rev 41185)
@@ -260,8 +260,6 @@
                                        node.AppendChild (ChildNodes 
[i].CloneNode (deep));
                        }
 
-                       if (IsReadOnly)
-                               node.SetReadOnly ();
                        return node;
                }
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlCDataSection.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlCDataSection.cs    2005-02-25 
07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlCDataSection.cs    2005-02-25 
09:39:56 UTC (rev 41185)
@@ -61,8 +61,6 @@
                public override XmlNode CloneNode (bool deep)
                {
                        XmlNode n = new XmlCDataSection (Data, OwnerDocument); 
// CDATA nodes have no children.
-                       if (IsReadOnly)
-                               n.SetReadOnly ();
                        return n;
                }
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlComment.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlComment.cs 2005-02-25 07:40:58 UTC 
(rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlComment.cs 2005-02-25 09:39:56 UTC 
(rev 41185)
@@ -72,8 +72,6 @@
                {
                        // discard deep because Comments have no children.
                        XmlNode n = new XmlComment(Value, OwnerDocument); 
-                       if (IsReadOnly)
-                               n.SetReadOnly ();
                        return n;
                }
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlElement.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlElement.cs 2005-02-25 07:40:58 UTC 
(rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlElement.cs 2005-02-25 09:39:56 UTC 
(rev 41185)
@@ -251,8 +251,6 @@
                                        node.AppendChild (ChildNodes 
[i].CloneNode (true));
                        }
 
-                       if (IsReadOnly)
-                               node.SetReadOnly ();
                        return node;
                }
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlEntity.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlEntity.cs  2005-02-25 07:40:58 UTC 
(rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlEntity.cs  2005-02-25 09:39:56 UTC 
(rev 41185)
@@ -140,17 +140,17 @@
                {
                        // No effect.
                }
-
-               internal void SetEntityContent ()
-               {
+
+               internal void SetEntityContent ()
+               {
                        if (FirstChild != null)
                                return;
 
                        XmlDocumentType doctype = OwnerDocument.DocumentType;
-
-                       if (doctype == null)
-                               return;
 
+                       if (doctype == null)
+                               return;
+
                        DTDEntityDeclaration decl = doctype.DTD.EntityDecls 
[name];
                        if (decl == null)
                                return;
@@ -167,9 +167,7 @@
                                if(n == null) break;
                                InsertBefore (n, null, false, false);
                        } while (true);
-
-                       SetReadOnly (this);
-               }
+               }
                #endregion
        }
 }

Modified: trunk/mcs/class/System.XML/System.Xml/XmlEntityReference.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlEntityReference.cs 2005-02-25 
07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlEntityReference.cs 2005-02-25 
09:39:56 UTC (rev 41185)
@@ -122,7 +122,6 @@
                                for (int i = 0; i < ent.ChildNodes.Count; i++)
                                        InsertBefore (ent.ChildNodes 
[i].CloneNode (true), null, false, true);
                        }
-                       SetReadOnly (this);
                }
        }
 }

Modified: trunk/mcs/class/System.XML/System.Xml/XmlNode.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlNode.cs    2005-02-25 07:40:58 UTC 
(rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlNode.cs    2005-02-25 09:39:56 UTC 
(rev 41185)
@@ -50,7 +50,6 @@
                XmlNode parentNode;
                XmlLinkedNode lastLinkedChild;
                XmlNodeListChildren childNodes;
-               bool isReadOnly;
 
                #endregion
 
@@ -144,7 +143,30 @@
                }
 
                public virtual bool IsReadOnly {
-                       get { return isReadOnly; }
+                       get 
+                       {
+                               XmlNode curNode = this;
+                               do
+                               {
+                                       switch (curNode.NodeType) 
+                                       {
+                                               case 
XmlNodeType.EntityReference:
+                                               case XmlNodeType.Entity:
+                                                       return true;
+
+                                               case XmlNodeType.Attribute:
+                                                       curNode = 
((XmlAttribute)curNode).OwnerElement;
+                                                       break;
+
+                                               default:
+                                                       curNode = 
curNode.ParentNode;
+                                                       break;
+                                       }
+                               }
+                               while (curNode != null) ;
+
+                               return false;
+                       }
                }
 
                [System.Runtime.CompilerServices.IndexerName("Item")]
@@ -761,21 +783,6 @@
                        return ((IHasXmlNode) iter.Current).GetNode ();
                }
 
-               internal static void SetReadOnly (XmlNode n)
-               {
-                       if (n.Attributes != null)
-                               for (int i = 0; i < n.Attributes.Count; i++)
-                                       SetReadOnly (n.Attributes [i]);
-                       for (int i = 0; i < n.ChildNodes.Count; i++)
-                               SetReadOnly (n.ChildNodes [i]);
-                       n.isReadOnly = true;
-               }
-
-               internal void SetReadOnly ()
-               {
-                       isReadOnly = true;
-               }
-
                public virtual bool Supports (string feature, string version)
                {
                        if (String.Compare (feature, "xml", true, 
CultureInfo.InvariantCulture) == 0 // not case-sensitive

Modified: trunk/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs   
2005-02-25 07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlProcessingInstruction.cs   
2005-02-25 09:39:56 UTC (rev 41185)
@@ -111,8 +111,6 @@
                public override XmlNode CloneNode (bool deep)
                {
                        XmlNode n = new XmlProcessingInstruction (target, data, 
OwnerDocument);
-                       if (IsReadOnly)
-                               n.SetReadOnly ();
                        return n;
                }
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs   
2005-02-25 07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlSignificantWhitespace.cs   
2005-02-25 09:39:56 UTC (rev 41185)
@@ -73,8 +73,6 @@
                public override XmlNode CloneNode (bool deep)
                {
                        XmlNode n = new XmlSignificantWhitespace (Data, 
OwnerDocument);
-                       if (IsReadOnly)
-                               n.SetReadOnly ();
                        return n;
                }
 

Modified: trunk/mcs/class/System.XML/System.Xml/XmlText.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlText.cs    2005-02-25 07:40:58 UTC 
(rev 41184)
+++ trunk/mcs/class/System.XML/System.Xml/XmlText.cs    2005-02-25 09:39:56 UTC 
(rev 41185)
@@ -76,8 +76,6 @@
                public override XmlNode CloneNode (bool deep)
                {
                        XmlText newText = OwnerDocument.CreateTextNode(Data);
-                       if (IsReadOnly)
-                               newText.SetReadOnly ();
                        return newText;
                }
 

Modified: trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog        2005-02-25 
07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog        2005-02-25 
09:39:56 UTC (rev 41185)
@@ -1,5 +1,10 @@
 2005-02-25  Atsushi Enomoto <[EMAIL PROTECTED]>
 
+       * XmlNodeTests.cs : added Clone() of readonly node returns a node
+         that is not readonly.
+
+2005-02-25  Atsushi Enomoto <[EMAIL PROTECTED]>
+
        * XmlAttributeTests.cs : added nonNCName Prefix case.
 
 2005-02-24  Atsushi Enomoto <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs  2005-02-25 
07:40:58 UTC (rev 41184)
+++ trunk/mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs  2005-02-25 
09:39:56 UTC (rev 41185)
@@ -445,5 +445,22 @@
                        XmlAttribute attr = doc.CreateAttribute ("attr");
                        AssertEquals (String.Empty, attr.BaseURI);
                }
+
+               [Test]
+               public void CloneReadonlyNode ()
+               {
+                       // Clone() should return such node that is not readonly
+                       string dtd = "<!DOCTYPE root ["
+                               + "<!ELEMENT root (#PCDATA|foo)*>"
+                               + "<!ELEMENT foo EMPTY>"
+                               + "<!ENTITY ent1 '<foo /><![CDATA[cdata]]>'>]>";
+                       string xml = dtd + "<root>&ent1;</root>";
+
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml (xml);
+                       XmlNode n = doc.DocumentElement.FirstChild.FirstChild;
+                       Assert ("#1", n.IsReadOnly);
+                       Assert ("#2", !n.CloneNode (true).IsReadOnly);
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to