C# Class 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.

Afficher le fichier Open project: antlr/antlr4 Class Usage Examples

Protected Properties

Свойство Type Description
elements Antlr4.Runtime.Tree.Xpath.XPathElement[]
parser Parser
path string

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
GetXPathElement ( IToken wordToken, bool anywhere ) : XPathElement

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

Method Details

Evaluate() public méthode

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
Résultat ICollection

FindAll() public static méthode

public static FindAll ( IParseTree tree, string xpath, Parser parser ) : ICollection
tree IParseTree
xpath string
parser Parser
Résultat ICollection

GetXPathElement() protected méthode

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
Résultat XPathElement

Split() public méthode

public Split ( string path ) : Antlr4.Runtime.Tree.Xpath.XPathElement[]
path string
Résultat Antlr4.Runtime.Tree.Xpath.XPathElement[]

XPath() public méthode

public XPath ( Parser parser, string path ) : System
parser Parser
path string
Résultat System

Property Details

elements protected_oe property

protected XPathElement[],Antlr4.Runtime.Tree.Xpath elements
Résultat Antlr4.Runtime.Tree.Xpath.XPathElement[]

parser protected_oe property

protected Parser parser
Résultat Parser

path protected_oe property

protected string path
Résultat string