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
6 changes: 3 additions & 3 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ func (b *builder) processFilter(root *filterNode, flags flag, props *builderProp
switch qyFunc.Input.(type) {
case *filterQuery:
cond = &lastFuncQuery{Input: qyFunc.Input}
case *groupQuery:
cond = &lastFuncQuery{Input: qyFunc.Input.Clone()}
}
}
}
Expand Down Expand Up @@ -689,9 +691,7 @@ func (b *builder) processNode(root node, flags flag, props *builderProp) (q quer
return
}
q = &groupQuery{Input: q}
if b.firstInput == nil {
b.firstInput = q
}
b.firstInput = q
}
b.parseDepth--
return
Expand Down
4 changes: 4 additions & 0 deletions xpath_predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ func TestPositions(t *testing.T) {
test_xpath_elements(t, employee_example, `//employee[last()]`, 13)
test_xpath_elements(t, employee_example, `//employee[position() = last()]`, 13)
test_xpath_elements(t, book_example, `//book[@category = "web"][2]`, 25)
test_xpath_elements(t, book_example, `//book[@category = "web"][last()]`, 25)
test_xpath_elements(t, book_example, `(//book[@category = "web"])[2]`, 25)
test_xpath_elements(t, book_example, `(//book[@category = "web"])[last()]`, 25)
test_xpath_elements(t, employee_example, `(//employee)[last()]`, 13)
test_xpath_elements(t, book_example, `(//author)[last()]`, 27)
}

func TestPredicates(t *testing.T) {
Expand Down
Loading