Ver Fonte

2004-07-30 Atsushi Enomoto <[email protected]>

	* DTMXPathNavigator.cs :
	  Fixed IsSamePosition(). currentAttr and currentNS are not always
	  the same when current is attribute or current is namespace.
	* XPathNavigatorReader.cs : Fixed NodeType - 1) When attribute value is
	  being consumed, then node type should be Text, and 2) Root node is
	  usually mapped to Document, but XmlReader never returns Document,
	  just None (both on Initial state and EndOfFile state).

svn path=/trunk/mcs/; revision=31656
Atsushi Eno há 21 anos atrás
pai
commit
f430da5aa0

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

@@ -1,3 +1,13 @@
+2004-07-30  Atsushi Enomoto <[email protected]>
+
+	* DTMXPathNavigator.cs :
+	  Fixed IsSamePosition(). currentAttr and currentNS are not always
+	  the same when current is attribute or current is namespace.
+	* XPathNavigatorReader.cs : Fixed NodeType - 1) When attribute value is
+	  being consumed, then node type should be Text, and 2) Root node is
+	  usually mapped to Document, but XmlReader never returns Document,
+	  just None (both on Initial state and EndOfFile state).
+
 2004-07-30  Atsushi Enomoto <[email protected]>
 
 	* XPathNavigatorReader.cs : fixed GetAttributeNavigator() that

+ 10 - 5
mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator.cs

@@ -366,11 +366,16 @@ namespace Mono.Xml.XPath
 			if (another == null || another.document != this.document)
 				return false;
 
-			return this.currentNode == another.currentNode &&
-				this.currentAttr == another.currentAttr &&
-				this.currentIsAttr == another.currentIsAttr &&
-				this.currentIsNode == another.currentIsNode &&
-				this.currentNs == another.currentNs;
+			if (this.currentNode != another.currentNode ||
+				this.currentIsAttr != another.currentIsAttr ||
+				this.currentIsNode != another.currentIsNode)
+				return false;
+
+			if (currentIsAttr)
+				return this.currentAttr == another.currentAttr;
+			else if (!currentIsNode)
+				return this.currentNs == another.currentNs;
+			return true;
 		}
 
 		public override bool MoveTo (XPathNavigator other)

+ 14 - 4
mcs/class/System.XML/Mono.Xml.XPath/XPathNavigatorReader.cs

@@ -65,6 +65,16 @@ namespace Mono.Xml.XPath
 					return XmlNodeType.None;
 				if (endElement)
 					return XmlNodeType.EndElement;
+				if (attributeValueConsumed) {
+					switch (current.NodeType) {
+					case XPathNodeType.Whitespace:
+						return XmlNodeType.Whitespace;
+					case XPathNodeType.SignificantWhitespace:
+						return XmlNodeType.SignificantWhitespace;
+					default:
+						return XmlNodeType.Text;
+					}
+				}
 
 				switch (current.NodeType) {
 				case XPathNodeType.Namespace:
@@ -77,7 +87,8 @@ namespace Mono.Xml.XPath
 				case XPathNodeType.ProcessingInstruction:
 					return XmlNodeType.ProcessingInstruction;
 				case XPathNodeType.Root:
-					return XmlNodeType.Document;
+					// It is actually Document, but in XmlReader there is no such situation to return Document.
+					return XmlNodeType.None;
 				case XPathNodeType.SignificantWhitespace:
 					return XmlNodeType.SignificantWhitespace;
 				case XPathNodeType.Text:
@@ -420,16 +431,16 @@ namespace Mono.Xml.XPath
 					}
 					current.MoveToParent ();
 					depth--;
+					endElement = (current.NodeType == XPathNodeType.Element);
 					if (current.IsSamePosition (root)) {
 						if (current.NodeType == XPathNodeType.Element)
 							nextIsEOF = true;
 						else {
+							endElement = false;
 							eof = true;
 							return false;
 						}
 					}
-					if (current.NodeType == XPathNodeType.Element)
-						endElement = true;
 				} else
 					endElement = false;
 			}
@@ -611,7 +622,6 @@ namespace Mono.Xml.XPath
 		}
 
 		public override bool ReadAttributeValue () {
-			// Nop. In fact, it is impossible to consider it.
 			if (NodeType != XmlNodeType.Attribute)
 				return false;
 			if (attributeValueConsumed)