Przeglądaj źródła

2004-03-16 Atsushi Enomoto <[email protected]>

	* XmlDocumentNavigator.cs : Value should return concatenated string for
	  sequential text nodes. Considered detached nodes, the result of
	  MoveToParent() should be checked.

svn path=/trunk/mcs/; revision=24107
Atsushi Eno 22 lat temu
rodzic
commit
3df559acfa

+ 6 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,9 @@
+2004-03-16  Atsushi Enomoto <[email protected]>
+
+	* XmlDocumentNavigator.cs : Value should return concatenated string for 
+	  sequential text nodes. Considered detached nodes, the result of 
+	  MoveToParent() should be checked.
+
 2004-03-15  Atsushi Enomoto <[email protected]>
 
 	* XmlReader.cs : ReadInnerXml()/ReadOuterXml() should not bork when

+ 15 - 2
mcs/class/System.XML/System.Xml/XmlDocumentNavigator.cs

@@ -149,10 +149,22 @@ namespace System.Xml
 				case XPathNodeType.Attribute:
 				case XPathNodeType.Comment:
 				case XPathNodeType.ProcessingInstruction:
+					return node.Value;
 				case XPathNodeType.Text:
 				case XPathNodeType.Whitespace:
 				case XPathNodeType.SignificantWhitespace:
-					return node.Value;
+					string value = node.Value;
+					for (XmlNode n = node.NextSibling; n != null; n = n.NextSibling) {
+						switch (n.XPathNodeType) {
+						case XPathNodeType.Text:
+						case XPathNodeType.Whitespace:
+						case XPathNodeType.SignificantWhitespace:
+							value += n.Value;
+							continue;
+						}
+						break;
+					}
+					return value;
 				case XPathNodeType.Element:
 				case XPathNodeType.Root:
 					return node.InnerText;
@@ -239,7 +251,8 @@ namespace System.Xml
 		public override bool MoveToFirst ()
 		{
 			if (nsNode == null && node.NodeType != XmlNodeType.Attribute && node.ParentNode != null) {
-				MoveToParent ();
+				if (!MoveToParent ())
+					return false;
 				// Follow these 2 steps so that we can skip 
 				// some types of nodes .
 				MoveToFirstChild ();