MCPcopy Create free account
hub / github.com/antchfx/xpath / Compile

Function Compile

xpath.go:140–152  ·  view source on GitHub ↗

Compile compiles an XPath expression string.

(expr string)

Source from the content-addressed store, hash-verified

138
139// Compile compiles an XPath expression string.
140func Compile(expr string) (*Expr, error) {
141 if expr == "" {
142 return nil, errors.New("expr expression is nil")
143 }
144 qy, err := build(expr, nil)
145 if err != nil {
146 return nil, err
147 }
148 if qy == nil {
149 return nil, fmt.Errorf(fmt.Sprintf("undeclared variable in XPath expression: %s", expr))
150 }
151 return &Expr{s: expr, q: qy}, nil
152}
153
154// MustCompile compiles an XPath expression string and ignored error.
155func MustCompile(expr string) *Expr {

Callers 7

ExampleFunction · 0.92
test_xpath_evalFunction · 0.85
TestCompileFunction · 0.85
TestInvalidXPathFunction · 0.85
SelectFunction · 0.85
MustCompileFunction · 0.85
Test_func_matchesFunction · 0.85

Calls 1

buildFunction · 0.85

Tested by 5

ExampleFunction · 0.74
test_xpath_evalFunction · 0.68
TestCompileFunction · 0.68
TestInvalidXPathFunction · 0.68
Test_func_matchesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…