1 using System;
2 using System.Collections;
3
4
5
6
7
8 namespace System.XPath
9 {
10 public UniquePtr<XPathObject> Evaluate(const ustring& xpathExpression, System.Dom.Node* node)
11 {
12 System.Lex.XmlParsingLog debugLog(Console.Out());
13 TimePoint startQuery = Now();
14 XPathLexer xpathLexer(xpathExpression, "", 0);
15 if (XPathDebugParsing())
16 {
17 xpathLexer.SetLog(&debugLog);
18 }
19 UniquePtr<XPathExpr> xpathExpr(XPathParser.Parse(xpathLexer));
20 TimePoint endQuery = Now();
21 if (XPathDebugQuery())
22 {
23 UniquePtr<System.Dom.Node> queryDom = xpathExpr->ToDom();
24 SetXPathQueryDom(Rvalue(queryDom));
25 SetXPathQueryDuration(endQuery - startQuery);
26 }
27 TimePoint startEvaluate = Now();
28 XPathContext context(node, 1, 1);
29 UniquePtr<XPathObject> result = xpathExpr->Evaluate(context);
30 TimePoint endEvaluate = Now();
31 if (XPathDebugQuery())
32 {
33 SetXPathExecuteDuration(endEvaluate - startEvaluate);
34 }
35 return result;
36 }
37 public UniquePtr<XPathObject> Evaluate(const ustring& xpathExpression, System.Dom.Document* document)
38 {
39 return Evaluate(xpathExpression, cast<System.Dom.Node*>(document));
40 }
41 }