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.

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
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