C# 클래스 Antlr4.Runtime.Tree.Xpath.XPath

Represent a subset of XPath XML path syntax for use in identifying nodes in parse trees.
Represent a subset of XPath XML path syntax for use in identifying nodes in parse trees.

Split path into words and separators / and // via ANTLR itself then walk path elements from left to right. At each separator-word pair, find set of nodes. Next stage uses those as work list.

The basic interface is ParseTree.findAll (tree, pathString, parser) . But that is just shorthand for:

 XPath p = new XPath (parser, pathString); return p. evaluate (tree); 

See org.antlr.v4.test.TestXPath for descriptions. In short, this allows operators:

/
root
//
anywhere
!
invert; this must appear directly after root or anywhere operator

and path elements:

ID
token name
'string'
any string literal token from the grammar
expr
rule name
*
wildcard matching any node

Whitespace is not allowed.

파일 보기 프로젝트 열기: antlr/antlr4 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
elements Antlr4.Runtime.Tree.Xpath.XPathElement[]
parser Parser
path string

공개 메소드들

메소드 설명
Evaluate ( IParseTree t ) : ICollection

Return a list of all nodes starting at t as root that satisfy the path. The root / is relative to the node passed to Evaluate(Antlr4.Runtime.Tree.IParseTree) .

FindAll ( IParseTree tree, string xpath, Parser parser ) : ICollection
Split ( string path ) : Antlr4.Runtime.Tree.Xpath.XPathElement[]
XPath ( Parser parser, string path ) : System

보호된 메소드들

메소드 설명
GetXPathElement ( IToken wordToken, bool anywhere ) : XPathElement

Convert word like * or ID or expr to a path element. anywhere is if // precedes the word.

메소드 상세

Evaluate() 공개 메소드

Return a list of all nodes starting at t as root that satisfy the path. The root / is relative to the node passed to Evaluate(Antlr4.Runtime.Tree.IParseTree) .
public Evaluate ( IParseTree t ) : ICollection
t IParseTree
리턴 ICollection

FindAll() 공개 정적인 메소드

public static FindAll ( IParseTree tree, string xpath, Parser parser ) : ICollection
tree IParseTree
xpath string
parser Parser
리턴 ICollection

GetXPathElement() 보호된 메소드

Convert word like * or ID or expr to a path element. anywhere is if // precedes the word.
protected GetXPathElement ( IToken wordToken, bool anywhere ) : XPathElement
wordToken IToken
anywhere bool
리턴 XPathElement

Split() 공개 메소드

public Split ( string path ) : Antlr4.Runtime.Tree.Xpath.XPathElement[]
path string
리턴 Antlr4.Runtime.Tree.Xpath.XPathElement[]

XPath() 공개 메소드

public XPath ( Parser parser, string path ) : System
parser Parser
path string
리턴 System

프로퍼티 상세

elements 보호되어 있는 프로퍼티

protected XPathElement[],Antlr4.Runtime.Tree.Xpath elements
리턴 Antlr4.Runtime.Tree.Xpath.XPathElement[]

parser 보호되어 있는 프로퍼티

protected Parser parser
리턴 Parser

path 보호되어 있는 프로퍼티

protected string path
리턴 string