I couldn't find a better resource for reporting a possible .NET Framework 1.1
(SP0 & 1) bug, so if this is not the proper forum, please let me know.
The problem appears to occur when using "self::" to match the current node
of an XPathNavigator. In this case the resulting XPathNodeIterator returns a
Count of 1 even though it is properly empty as evidenced by MoveNext()
returning false.
In the following sample code (compiled as a console program), the results
from Test 2 & 10 are not correct.
static void Main(string[] args)
{
XPathDocument doc = new XPathDocument(new
StringReader("<root><a></a></root>"));
XPathNavigator nav = doc.CreateNavigator();
nav.MoveToFirstChild(); // now at "root"
Console.Out.WriteLine("Current Node Name: {0}\n",nav.Name);
RunSelectTest(nav,"self::root",1);
RunSelectTest(nav,"self::nomatch",2);
RunSelectTest(nav,"../root",3);
RunSelectTest(nav,"../nomatch",4);
RunSelectTest(nav,"a/self::a",5);
RunSelectTest(nav,"a/self::nomatch",6);
RunSelectTest(nav,"a",7);
RunSelectTest(nav,"nomatch",8);
nav.MoveToFirstChild(); // now at "a"
RunSelectTest(nav,"self::a",9);
RunSelectTest(nav,"self::nomatch",10);
}
static void RunSelectTest( XPathNavigator nav, string xpath, int testId )
{
Console.Out.WriteLine("--- Test {0} (\"{1}\") ---",testId,xpath);
XPathNodeIterator iter = nav.Select(xpath);
Console.Out.WriteLine("Select Iter Count: {0}",iter.Count);
Console.Out.WriteLine("Select Iter MoveNext: {0}",iter.MoveNext());
Console.Out.WriteLine(string.Empty);
}
Thanks,
Jamie da Silva
Silverlake Software LLC