1 //------------------------------------------------------------------------------
2 // <copyright file="NamespaceQuery.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 NamespaceQuery : BaseAxisQuery {
16 private bool onNamespace;
18 public NamespaceQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type) : base(qyParent, Name, Prefix, Type) {}
19 private NamespaceQuery(NamespaceQuery other) : base(other) {
20 this.onNamespace = other.onNamespace;
23 public override void Reset() {
28 public override XPathNavigator Advance() {
31 currentNode = qyInput.Advance();
32 if (currentNode == null) {
36 currentNode = currentNode.Clone();
37 onNamespace = currentNode.MoveToFirstNamespace();
39 onNamespace = currentNode.MoveToNextNamespace();
43 if (matches(currentNode)) {
51 public override bool matches(XPathNavigator e) {
52 Debug.Assert(e.NodeType == XPathNodeType.Namespace);
53 if (e.Value.Length == 0) {
54 Debug.Assert(e.LocalName.Length == 0, "Only xmlns='' can have empty string as a value");
55 // Namespace axes never returns xmlns='',
56 // because it's not a NS declaration but rather undeclaration.
60 return Name.Equals(e.LocalName);
66 public override XPathNodeIterator Clone() { return new NamespaceQuery(this); }