Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (p *parser) parsePathExpr(n node) node {
// FilterExpr ::= PrimaryExpr | FilterExpr Predicate
func (p *parser) parseFilterExpr(n node) node {
opnd := p.parsePrimaryExpr(n)
if p.r.typ == itemLBracket {
for p.r.typ == itemLBracket {
opnd = newFilterNode(opnd, p.parsePredicate(opnd))
}
return opnd
Expand Down
9 changes: 9 additions & 0 deletions xpath_predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,12 @@ func TestNestedPredicates(t *testing.T) {
test_xpath_elements(t, employee_example, `//employee[./name[@from]]`, 8)
test_xpath_elements(t, employee_example, `//employee[.//name[@from = "CA"]]`, 8)
}

func TestChainedPredicateOnGroupedExpression(t *testing.T) {
test_xpath_count(t, employee_example, `(//employee)[1][false()]`, 0)
test_xpath_count(t, employee_example, `(//employee)[2][false()]`, 0)
test_xpath_count(t, employee_example, `(//employee)[1][@id = "2"]`, 0)
test_xpath_elements(t, employee_example, `(//employee)[1][true()]`, 3)
test_xpath_elements(t, employee_example, `(//employee)[1][@id = "1"]`, 3)
test_xpath_elements(t, employee_example, `(//employee)[2][@id = "2"]`, 8)
}