2006-11-10 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 10 Nov 2006 00:08:43 +0000 (00:08 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 10 Nov 2006 00:08:43 +0000 (00:08 -0000)
* XPathNavigator.cs : InnerXml should allow Text-only content. Fixed
  bug #79874, when tied to XPathNavigatorReader fix.

* XPathNavigatorReader.cs : removed node type restriction on
  initialization.  Fixed bug #79874, when tied to XPathNavigator fix.

* XPathNavigatorTests.cs : added test for bug #79874.

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

mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
mcs/class/System.XML/Mono.Xml.XPath/XPathNavigatorReader.cs
mcs/class/System.XML/System.Xml.XPath/ChangeLog
mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog
mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorTests.cs

index c9549948b6270dbada8c6329a18ea3e4ffee36e1..b21d0e774ce11c9b70d26434082f02c6936f6048 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-10  Atsushi Enomoto <atsushi@ximian.com>
+
+       * XPathNavigatorReader.cs : removed node type restriction on 
+         initialization.  Fixed bug #79874, when tied to XPathNavigator fix.
+
 2006-10-11  Atsushi Enomoto <atsushi@ximian.com>
 
        * XPathEditableDocument.cs : (XmlDocumentEditableNavigator)
index b02039c46565803ea643082b64cf80e29954d903..e6f81ae4163b0369d82bcb15176bc7eb25284cd6 100644 (file)
@@ -42,13 +42,6 @@ namespace Mono.Xml.XPath
        {\r
                public XPathNavigatorReader (XPathNavigator nav)\r
                {\r
-                       switch (nav.NodeType) {\r
-                       case XPathNodeType.Element:\r
-                       case XPathNodeType.Root:\r
-                               break;\r
-                       default:\r
-                               throw new InvalidOperationException (String.Format ("NodeType {0} is not supported to read as a subtree of an XPathNavigator.", nav.NodeType));\r
-                       }\r
                        current = nav.Clone ();\r
                }\r
 \r
index aedd0fe351dbac7d2d262b6071cf0fc11ed398bb..ce3d84539197c6781abdcbd400c27719ecbd8647 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-10  Atsushi Enomoto <atsushi@ximian.com>
+
+       * XPathNavigator.cs : InnerXml should allow Text-only content. Fixed
+         bug #79874, when tied to XPathNavigatorReader fix.
+
 2006-04-10  Atsushi Enomoto <atsushi@ximian.com>
 
        * XPathNavigator.cs : get_OuterXml() returns indented output, without
index 1d49cfff7cced545255bf97c3051c87d68103b23..311271ce55e9d83871662f4a544b0e726c57a6be 100644 (file)
@@ -886,7 +886,10 @@ namespace System.Xml.XPath
                                if (NodeType != XPathNodeType.Root)
                                        r.Read ();
                                StringWriter sw = new StringWriter ();
-                               XmlWriter xtw = XmlWriter.Create (sw);
+                               XmlWriterSettings s = new XmlWriterSettings ();
+                               s.ConformanceLevel = ConformanceLevel.Fragment;
+                               s.OmitXmlDeclaration = true;
+                               XmlWriter xtw = XmlWriter.Create (sw, s);
                                while (!r.EOF && r.Depth > depth)
                                        xtw.WriteNode (r, false);
                                return sw.ToString ();
@@ -910,6 +913,7 @@ namespace System.Xml.XPath
                                XmlWriterSettings s = new XmlWriterSettings ();
                                s.Indent = true;
                                s.OmitXmlDeclaration = true;
+                               s.ConformanceLevel = ConformanceLevel.Fragment;
                                StringBuilder sb = new StringBuilder ();
                                using (XmlWriter w = XmlWriter.Create (sb, s)) {
                                        WriteSubtree (w);
index 2a2f4aa8d269c8fc31d72ee7a947cfb6bfc3c4a6..c8b435553b0259a6ed2aad9a675f30dac1ad3a42 100644 (file)
@@ -1,3 +1,7 @@
+2006-10-27  Atsushi Enomoto <atsushi@ximian.com>
+
+       * XPathNavigatorTests.cs : added test for bug #79874.
+
 2006-10-27  Atsushi Enomoto <atsushi@ximian.com>
 
        * XPathNavigatorTests.cs : added (kind of) test for bug #46751.
index 8373e7c3c6c44bb115c0a39dd3cb1275c3b51395..19242a7fffa554da89fcd777df05a4ed7ce7ba08 100644 (file)
@@ -535,6 +535,22 @@ namespace MonoTests.System.Xml
                        nav.MoveToFirstChild ();
                        long l = nav.ValueAsLong;
                }
+
+               [Test] // bug #79874
+               public void InnerXmlText ()
+               {
+                       StringReader sr = new StringReader ("<Abc><Foo>Hello</Foo></Abc>");
+                       XPathDocument doc = new XPathDocument (sr);
+                       XPathNavigator nav = doc.CreateNavigator ();
+                       XPathNodeIterator iter = nav.Select ("/Abc/Foo");
+                       iter.MoveNext ();
+                       AssertEquals ("#1", "Hello", iter.Current.InnerXml);
+                       AssertEquals ("#2", "<Foo>Hello</Foo>", iter.Current.OuterXml);
+                       iter = nav.Select ("/Abc/Foo/text()");
+                       iter.MoveNext ();
+                       AssertEquals ("#3", String.Empty, iter.Current.InnerXml);
+                       AssertEquals ("#4", "Hello", iter.Current.OuterXml);
+               }
 #endif
        }
 }