1 //------------------------------------------------------------------------------
2 // <copyright file="XPathExpr.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.XPath {
12 using System.Collections;
13 using MS.Internal.Xml.XPath;
15 public enum XmlSortOrder {
20 public enum XmlCaseOrder {
26 public enum XmlDataType {
31 public enum XPathResultType {
36 Navigator = XPathResultType.String,
41 public abstract class XPathExpression {
42 internal XPathExpression(){}
44 public abstract string Expression { get; }
46 public abstract void AddSort(object expr, IComparer comparer);
48 public abstract void AddSort(object expr, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType);
50 public abstract XPathExpression Clone();
52 public abstract void SetContext(XmlNamespaceManager nsManager);
54 public abstract void SetContext(IXmlNamespaceResolver nsResolver);
56 public abstract XPathResultType ReturnType { get; }
58 public static XPathExpression Compile(string xpath) {
59 return Compile(xpath, /*nsResolver:*/null);
62 public static XPathExpression Compile(string xpath, IXmlNamespaceResolver nsResolver) {
64 Query query = new QueryBuilder().Build(xpath, out hasPrefix);
65 CompiledXpathExpr expr = new CompiledXpathExpr(query, xpath, hasPrefix);
66 if (null != nsResolver) {
67 expr.SetContext(nsResolver);
72 private void PrintQuery(XmlWriter w) {
73 ((CompiledXpathExpr)this).QueryTree.PrintQuery(w);