Author: kostat
Date: 2008-02-12 06:55:47 -0500 (Tue, 12 Feb 2008)
New Revision: 95494
Modified:
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/System.Xml.XPath/Iterator.cs
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/Test/System.Xml.XPath/SelectNodesTests.cs
Log:
merge -r95368:95369
Modified:
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/System.Xml.XPath/Iterator.cs
===================================================================
---
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/System.Xml.XPath/Iterator.cs
2008-02-12 11:52:20 UTC (rev 95493)
+++
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/System.Xml.XPath/Iterator.cs
2008-02-12 11:55:47 UTC (rev 95494)
@@ -367,27 +367,16 @@
{
navigators = new ArrayList ();
- XPathNavigator ancestors = startPosition.Clone ();
- if (!ancestors.MoveToParent ())
- return;
- while (ancestors.NodeType != XPathNodeType.Root) {
+ XPathNavigator ancestors = startPosition.Clone ();
+ while (ancestors.NodeType != XPathNodeType.Root &&
ancestors.MoveToParent ())
navigators.Add (ancestors.Clone ());
- ancestors.MoveToParent ();
- }
currentPosition = navigators.Count;
}
public override bool MoveNextCore ()
{
- if (navigators == null) {
+ if (navigators == null)
CollectResults ();
- if (startPosition.NodeType !=
XPathNodeType.Root) {
- // First time it returns Root
- _nav.MoveToRoot ();
- Current.MoveTo (_nav);
- return true;
- }
- }
if (currentPosition == 0)
return false;
_nav.MoveTo ((XPathNavigator) navigators
[--currentPosition]);
Modified:
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/Test/System.Xml.XPath/SelectNodesTests.cs
===================================================================
---
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/Test/System.Xml.XPath/SelectNodesTests.cs
2008-02-12 11:52:20 UTC (rev 95493)
+++
branches/mainsoft/gh20/mcs_Customer1/class/System.XML/Test/System.Xml.XPath/SelectNodesTests.cs
2008-02-12 11:55:47 UTC (rev 95494)
@@ -276,6 +276,22 @@
AssertEquals ("hoge", nl [1].LocalName);
AssertEquals ("xml", nl [2].LocalName);
AssertEquals (3, nl.Count);
+ }
+
+ [Test]
+ public void AncestorAxis () {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<foo><bar><baz><bax
/></baz></bar></foo>");
+
+ XmlNode bar = doc.GetElementsByTagName ("bar") [0];
+ XmlElement barClone = (XmlElement) bar.CloneNode (true);
+ XmlNodeList baxs = barClone.GetElementsByTagName
("bax");
+
+ XmlNode bax = baxs [0];
+ XmlNodeList ans = bax.SelectNodes ("ancestor::*");
+ AssertEquals (2, ans.Count);
+ AssertEquals ("bar", ans [0].Name);
+ AssertEquals ("baz", ans [1].Name);
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches