1 //------------------------------------------------------------------------------
2 // <copyright file="DescendantQuery.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;
14 internal abstract class DescendantBaseQuery : BaseAxisQuery {
15 protected bool matchSelf;
16 protected bool abbrAxis;
18 public DescendantBaseQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type, bool matchSelf, bool abbrAxis) : base(qyParent, Name, Prefix, Type) {
19 this.matchSelf = matchSelf;
20 this.abbrAxis = abbrAxis;
22 public DescendantBaseQuery(DescendantBaseQuery other) : base(other) {
23 this.matchSelf = other.matchSelf;
24 this.abbrAxis = other.abbrAxis;
27 public override XPathNavigator MatchNode(XPathNavigator context) {
28 if (context != null) {
30 throw XPathException.Create(Res.Xp_InvalidPattern);
32 XPathNavigator result = null;
33 if (matches(context)) {
35 if ((result = qyInput.MatchNode(context)) != null) {
40 XPathNavigator anc = context.Clone();
41 while (anc.MoveToParent()) {
42 if ((result = qyInput.MatchNode(anc)) != null) {
51 public override void PrintQuery(XmlWriter w) {
52 w.WriteStartElement(this.GetType().Name);
54 w.WriteAttributeString("self", "yes");
57 w.WriteAttributeString("name", Prefix.Length != 0 ? Prefix + ':' + Name : Name);
59 if (TypeTest != XPathNodeType.Element) {
60 w.WriteAttributeString("nodeType", TypeTest.ToString());
62 qyInput.PrintQuery(w);