2010-04-21 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 21 Apr 2010 08:41:54 +0000 (08:41 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 21 Apr 2010 08:41:54 +0000 (08:41 -0000)
* XDocument.cs : don't prohibit DTD.
* XNodeNavigator.cs : do not return true in MoveToFirstChild()
  when there is no child node. Fixed bug #594877.

* XNodeNavigatorTest.cs : added test for bug #594877. Enable and fix
  tests that were commented out.

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

mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
mcs/class/System.Xml.Linq/System.Xml.Linq/XDocument.cs
mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeNavigator.cs
mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog
mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeNavigatorTest.cs

index 98f08b9baf1edff55a933c0043c6cff9bcc33a1b..e21d7728f2e24e2a5dcedf4c990951121331483f 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XDocument.cs : don't prohibit DTD.
+       * XNodeNavigator.cs : do not return true in MoveToFirstChild()
+         when there is no child node. Fixed bug #594877.
+
 2010-04-02  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XContainer.cs : create snapshot copy first before removal of nodes.
index 73271ac03df8bae86f54fda3a30c927b0a1c9c6c..2255eae5bf18025d48188bb7eceed63046e5dca1 100644 (file)
@@ -119,6 +119,7 @@ namespace System.Xml.Linq
                public static XDocument Load (TextReader reader, LoadOptions options)
                {
                        XmlReaderSettings s = new XmlReaderSettings ();
+                       s.ProhibitDtd = false; // see XNodeNavigatorTest.MoveToId().
                        s.IgnoreWhitespace = (options & LoadOptions.PreserveWhitespace) == 0;
                        using (XmlReader r = XmlReader.Create (reader, s)) {
                                return LoadCore (r, options);
index a64ca7e882172c7fc07cdcc65ca39c7f9afd1528..ab252001f42e95e18620b29a14245e760e54ae02 100644 (file)
@@ -280,7 +280,7 @@ namespace System.Xml.Linq
                public override bool MoveToFirstChild ()
                {
                        XContainer c = node as XContainer;
-                       if (c == null)
+                       if (c == null || c.FirstNode == null)
                                return false;
                        node = c.FirstNode;
                        attr = null;
index a42c63bdbaf868cc76d6ac89a6f08e934ac657ce..083fa4612974bf5a3660a7e5af9abc97832d11ac 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XNodeNavigatorTest.cs : added test for bug #594877. Enable and fix
+         tests that were commented out.
+
 2010-04-02  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XElementTest.cs : added test for bug #592435.
index 3e9ef5d92e2dff226fee2de0a0c78275187be2bc..c0694df42d1e48d2cbb8bb419ce3e420621fe660 100644 (file)
@@ -37,7 +37,6 @@ namespace MonoTests.System.Xml.Linq
        [TestFixture]
        public class XNodeNavigatorTest
        {
-/* It does not compile probably due to bug #359733.
                [Test]
                public void MoveToNext ()
                {
@@ -50,7 +49,8 @@ namespace MonoTests.System.Xml.Linq
                }
 
                [Test]
-               public void MoveToId () // Not supported
+               [ExpectedException (typeof (NotSupportedException))]
+               public void MoveToId () // ID is not supported here.
                {
                        string xml = @"
 <!DOCTYPE root [
@@ -59,11 +59,20 @@ namespace MonoTests.System.Xml.Linq
 <!ATTLIST foo id ID #IMPLIED>
 <!ATTLIST bar id ID #IMPLIED>
 ]>
-<root><foo id='foo' /><bar id='bar' /></root>",
+<root><foo id='foo' /><bar id='bar' /></root>";
                        XDocument doc = XDocument.Parse (xml, LoadOptions.SetLineInfo);
                        XPathNavigator nav = doc.CreateNavigator ();
                        nav.MoveToId ("foo");
                }
-*/
+
+               [Test]
+               public void Bug594877 ()
+               {
+                       string data = "<rt> <objsur t=\"o\" guid=\"06974d9a-ff86-4e1c-a3e5-7ce8c961dcb9\" /> </rt>";
+                       XElement xeOldOwner = XElement.Parse(data);
+                       string xpathOld = String.Format(".//objsur[@t='o']");
+                       XElement xeOldRef = xeOldOwner.XPathSelectElement(xpathOld);
+                       Assert.AreEqual ("<objsur t='o' guid='06974d9a-ff86-4e1c-a3e5-7ce8c961dcb9' />".Replace ('\'', '"'), xeOldRef.ToString (), "#1");
+               }
        }
 }