1 //------------------------------------------------------------------------------
2 // <copyright file="AttributeQuery.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace MS.Internal.Xml.XPath {
11 using System.Xml.XPath;
12 using System.Diagnostics;
13 using System.Globalization;
15 internal sealed class AttributeQuery : BaseAxisQuery {
16 private bool onAttribute = false;
18 public AttributeQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type) : base(qyParent, Name, Prefix, Type) {}
19 private AttributeQuery(AttributeQuery other) : base(other) {
20 this.onAttribute = other.onAttribute;
22 public override void Reset() {
27 public override XPathNavigator Advance() {
30 currentNode = qyInput.Advance();
31 if (currentNode == null) {
35 currentNode = currentNode.Clone();
36 onAttribute = currentNode.MoveToFirstAttribute();
38 onAttribute = currentNode.MoveToNextAttribute();
42 Debug.Assert(! currentNode.NamespaceURI.Equals(XmlReservedNs.NsXmlNs));
43 if (matches(currentNode)) {
51 public override XPathNavigator MatchNode(XPathNavigator context) {
52 if (context != null) {
53 if (context.NodeType == XPathNodeType.Attribute && matches(context)) {
54 XPathNavigator temp = context.Clone();
55 if (temp.MoveToParent()) {
56 return qyInput.MatchNode(temp);
63 public override XPathNodeIterator Clone() { return new AttributeQuery(this); }