2003-12-11 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 11 Dec 2003 05:43:12 +0000 (05:43 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 11 Dec 2003 05:43:12 +0000 (05:43 -0000)
* XmlDocument.cs : Fixed ReadNode() to call AppendChild() to document
  after setting all attribute nodes. Modified ReadNode() to handle
  Depth comparison and error handling (!= to <). It allows MS's
  SgmlReader bug that returns incorrect Depth.

svn path=/trunk/mcs/; revision=21014

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/XmlDocument.cs

index 238afb37ff370d418ced5255753a2b0d93aecce6..e5baa898999cd4d932ee49911619c0195a4ae762 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-11  Atsushi Enomoto  <ginga@kit.hi-ho.ne.jp>
+
+       * XmlDocument.cs : Fixed ReadNode() to call AppendChild() to document
+         after setting all attribute nodes. Modified ReadNode() to handle
+         Depth comparison and error handling (!= to <). It allows MS's
+         SgmlReader bug that returns incorrect Depth.
+
 2003-12-11  Atsushi Enomoto  <ginga@kit.hi-ho.ne.jp>
 
        * XmlDocumentNavigator.cs : Fixed MoveToNextAttribute (and 
index c976b9726160e31ab4d7d4b3d341fef30d932683..cf4aec2e0119b2d59eaa61eca8eed2fef0808550 100644 (file)
@@ -767,10 +767,6 @@ namespace System.Xml
                                case XmlNodeType.Element:
                                        XmlElement element = CreateElement (reader.Prefix, reader.LocalName, reader.NamespaceURI);
                                        element.IsEmpty = reader.IsEmptyElement;
-                                       if(currentNode != null)
-                                               currentNode.AppendChild (element);
-                                       else
-                                               resultNode = element;
 
                                        // set the element's attributes.
                                        while (reader.MoveToNextAttribute ()) {
@@ -779,6 +775,12 @@ namespace System.Xml
 
                                        reader.MoveToElement ();
 
+                                       // MS.NET adds element to document after its attributes are filled.
+                                       if(currentNode != null)
+                                               currentNode.AppendChild (element);
+                                       else
+                                               resultNode = element;
+
                                        if (!reader.IsEmptyElement)
                                                currentNode = element;
 
@@ -867,7 +869,7 @@ namespace System.Xml
                                        break;
                        } while (ignoredWhitespace || reader.Depth > startDepth ||
                                (reader.Depth == startDepth && reader.NodeType == XmlNodeType.EndElement));
-                       if (startDepth != reader.Depth && reader.EOF)
+                       if (startDepth < reader.Depth && reader.EOF)
                                throw new XmlException ("Unexpected end of xml reader.");
                        return resultNode != null ? resultNode : newNode;
                }