Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2005-12-13 18:18:30 +0300
committerAtsushi Eno <atsushieno@gmail.com>2005-12-13 18:18:30 +0300
commit229263cfc1c08cdba0f50d3a8c38101aef243e93 (patch)
tree508fcafaba92df38cafae9c0773a72cc779cdd2b /mcs/class/System.XML/System.Xml.XPath
parent502f0ff923a9f3f03681890c3e5bba48c547b299 (diff)
2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
* XPathNavigator.cs : Reimplemented MoveToFollowing() to avoid inefficient MoveToDescendant() and to match .NET 2.0 behavior. * XPathEditableNavigatorTests.cs : added tests for MoveToFollowing(). svn path=/trunk/mcs/; revision=54296
Diffstat (limited to 'mcs/class/System.XML/System.Xml.XPath')
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/ChangeLog5
-rw-r--r--mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs97
2 files changed, 55 insertions, 47 deletions
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
index c640d57f1a2..ac73bb0c65e 100644
--- a/mcs/class/System.XML/System.Xml.XPath/ChangeLog
+++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog
@@ -1,5 +1,10 @@
2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
+ * XPathNavigator.cs : Reimplemented MoveToFollowing() to avoid
+ inefficient MoveToDescendant() and to match .NET 2.0 behavior.
+
+2005-12-13 Atsushi Enomoto <atsushi@ximian.com>
+
* XPathNavigator.cs : ReplaceSelf() should allow document fragment.
Moved implementation to XPathEditableDocument.
diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
index 85a6f781158..ec8831684fe 100644
--- a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
+++ b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs
@@ -721,16 +721,6 @@ namespace System.Xml.XPath
return MoveTo (SelectChildren (localName, namespaceURI));
}
- bool MoveToDescendant (XPathNodeType type)
- {
- return MoveTo (SelectDescendants (type, false));
- }
-
- bool MoveToDescendant (string localName, string namespaceURI)
- {
- return MoveTo (SelectDescendants (localName, namespaceURI, false));
- }
-
public virtual bool MoveToNext (string localName, string namespaceURI)
{
XPathNavigator nav = Clone ();
@@ -756,76 +746,89 @@ namespace System.Xml.XPath
return false;
}
- [MonoTODO]
public virtual bool MoveToFollowing (string localName,
string namespaceURI)
{
return MoveToFollowing (localName, namespaceURI, null);
}
- [MonoTODO]
public virtual bool MoveToFollowing (string localName,
string namespaceURI, XPathNavigator end)
{
+ if (localName == null)
+ throw new ArgumentNullException ("localName");
+ if (namespaceURI == null)
+ throw new ArgumentNullException ("namespaceURI");
+ localName = NameTable.Get (localName);
+ if (localName == null)
+ return false;
+ namespaceURI = NameTable.Get (namespaceURI);
+ if (namespaceURI == null)
+ return false;
+
XPathNavigator nav = Clone ();
- bool skip = false;
+ switch (nav.NodeType) {
+ case XPathNodeType.Attribute:
+ case XPathNodeType.Namespace:
+ nav.MoveToParent ();
+ break;
+ }
do {
- if (!skip && nav.MoveToDescendant (localName,
- namespaceURI)) {
- if (end != null) {
- switch (nav.ComparePosition (end)) {
- case XmlNodeOrder.After:
- case XmlNodeOrder.Unknown:
- return false;
+ if (!nav.MoveToFirstChild ()) {
+ do {
+ if (!nav.MoveToNext ()) {
+ if (!nav.MoveToParent ())
+ return false;
}
- }
+ else
+ break;
+ } while (true);
+ }
+ if (end != null && end.IsSamePosition (nav))
+ return false;
+ if (object.ReferenceEquals (localName, nav.LocalName) &&
+ object.ReferenceEquals (namespaceURI, nav.NamespaceURI)) {
MoveTo (nav);
return true;
}
- else
- skip = false;
- if (!nav.MoveToNext ()) {
- if (!nav.MoveToParent ())
- break;
- skip = true;
- }
} while (true);
- return false;
}
- [MonoTODO]
public virtual bool MoveToFollowing (XPathNodeType type)
{
return MoveToFollowing (type, null);
}
- [MonoTODO]
public virtual bool MoveToFollowing (XPathNodeType type,
XPathNavigator end)
{
+ if (type == XPathNodeType.Root)
+ return false; // will never match
XPathNavigator nav = Clone ();
- bool skip = false;
+ switch (nav.NodeType) {
+ case XPathNodeType.Attribute:
+ case XPathNodeType.Namespace:
+ nav.MoveToParent ();
+ break;
+ }
do {
- if (!skip && nav.MoveToDescendant (type)) {
- if (end != null) {
- switch (nav.ComparePosition (end)) {
- case XmlNodeOrder.After:
- case XmlNodeOrder.Unknown:
- return false;
+ if (!nav.MoveToFirstChild ()) {
+ do {
+ if (!nav.MoveToNext ()) {
+ if (!nav.MoveToParent ())
+ return false;
}
- }
+ else
+ break;
+ } while (true);
+ }
+ if (end != null && end.IsSamePosition (nav))
+ return false;
+ if (nav.NodeType == type) {
MoveTo (nav);
return true;
}
- else
- skip = false;
- if (!nav.MoveToNext ()) {
- if (!nav.MoveToParent ())
- break;
- skip = true;
- }
} while (true);
- return false;
}
[MonoTODO]