Просмотр исходного кода

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

	* XPathNavigator.cs, Iterator.cs : Considered detached nodes, the
	  result of MoveToParent() should be checked.

svn path=/trunk/mcs/; revision=24106
Atsushi Eno 22 лет назад
Родитель
Сommit
1fdaec5cc7

+ 5 - 0
mcs/class/System.XML/System.Xml.XPath/ChangeLog

@@ -1,3 +1,8 @@
+2004-03-16  Atsushi Enomoto  <[email protected]>
+
+	* XPathNavigator.cs, Iterator.cs : Considered detached nodes, the 
+	  result of MoveToParent() should be checked.
+
 2004-02-17  Atsushi Enomoto  <[email protected]>
 
 	* XPathNavigator.cs : Only child and attribute axes are allowed for

+ 4 - 2
mcs/class/System.XML/System.Xml.XPath/Iterator.cs

@@ -323,7 +323,8 @@ namespace System.Xml.XPath
 						i++;
 					}
 					positions.Add (i);
-					ancestors.MoveToParent ();
+					if (!ancestors.MoveToParent ())
+						break; // It is for detached nodes under XmlDocumentNavigator
 					_nav.MoveToParent ();
 				}
 
@@ -405,7 +406,8 @@ namespace System.Xml.XPath
 						i++;
 					}
 					positions.Add (i);
-					ancestors.MoveToParent ();
+					if (!ancestors.MoveToParent ())
+						break; // for detached nodes under XmlDocumentNavigator.
 					_nav.MoveToParent ();
 				} while (ancestors.NodeType != XPathNodeType.Root);
 				positions.Reverse ();

+ 4 - 3
mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs

@@ -81,7 +81,8 @@ namespace System.Xml.XPath
 			{
 				while (nDepth1 > nDepth2)
 				{
-					nav1.MoveToParent ();
+					if (!nav1.MoveToParent ())
+						break;
 					nDepth1 --;
 				}
 				if (nav1.IsSamePosition (nav2))
@@ -91,7 +92,8 @@ namespace System.Xml.XPath
 			{
 				while (nDepth1 < nDepth2)
 				{
-					nav2.MoveToParent ();
+					if (!nav2.MoveToParent ())
+						break;
 					nDepth2 --;
 				}
 				if (nav1.IsSamePosition (nav2))
@@ -270,7 +272,6 @@ namespace System.Xml.XPath
 			return Matches (Compile (xpath));
 		}
 
-		[MonoTODO]	// optimize...
 		public virtual bool Matches (XPathExpression expr)
 		{
 			Expression e = ((CompiledExpression) expr).ExpressionNode;