Compile compiles an XPath expression string.
(expr string)
| 138 | |
| 139 | // Compile compiles an XPath expression string. |
| 140 | func 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. |
| 155 | func MustCompile(expr string) *Expr { |
searching dependent graphs…