Prechádzať zdrojové kódy

2004-05-22 Atsushi Enomoto <[email protected]>

	* DefaultContext.cs : Add XPathNavigator input support for ToBoolean()
	  and ToNavigator().
	* Expression.cs : In Equality comparison, evaluate XPathNavigator in
	  the same as well as NodeSet. This fixes bug #59134.

svn path=/trunk/mcs/; revision=28237
Atsushi Eno 21 rokov pred
rodič
commit
2ead87db32

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

@@ -1,3 +1,10 @@
+2004-05-22  Atsushi Enomoto  <[email protected]>
+
+	* DefaultContext.cs : Add XPathNavigator input support for ToBoolean()
+	  and ToNavigator().
+	* Expression.cs : In Equality comparison, evaluate XPathNavigator in
+	  the same as well as NodeSet. This fixes bug #59134.
+
 2004-05-22  Atsushi Enomoto  <[email protected]>
 
 	* XPathAtomicValue.cs : missed NET_2_0.

+ 9 - 1
mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs

@@ -35,6 +35,10 @@ namespace System.Xml.XPath
 				BaseIterator iter = (BaseIterator) arg;
 				return iter.MoveNext ();
 			}
+			if (arg is XPathNavigator)
+			{
+				return ToBoolean (((XPathNavigator) arg).SelectChildren (XPathNodeType.All));
+			}
 			throw new ArgumentException ();
 		}
 
@@ -75,6 +79,10 @@ namespace System.Xml.XPath
 					return "";
 				return iter.Current.Value;
 			}
+			if (arg is XPathNavigator)
+			{
+				return ((XPathNavigator) arg).Value;
+			}
 			throw new ArgumentException ();
 		}
 
@@ -82,7 +90,7 @@ namespace System.Xml.XPath
 		{
 			if (arg == null)
 				throw new ArgumentNullException ();
-			if (arg is BaseIterator)
+			if (arg is BaseIterator || arg is XPathNavigator)
 				arg = ToString (arg);	// follow on
 			if (arg is string) {
 				string s = arg as string;

+ 6 - 0
mcs/class/System.XML/System.Xml.XPath/Expression.cs

@@ -595,6 +595,12 @@ namespace System.Xml.XPath
 			if (typeR == XPathResultType.Any)
 				typeR = GetReturnType (_right.Evaluate (iter));
 
+			// Regard RTF as nodeset
+			if (typeL == XPathResultType.Navigator)
+				typeL = XPathResultType.NodeSet;
+			if (typeR == XPathResultType.Navigator)
+				typeR = XPathResultType.NodeSet;
+
 			if (typeL == XPathResultType.NodeSet || typeR == XPathResultType.NodeSet)
 			{
 				Expression left, right;