Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#188 made
last()count the nodes that afollowingorfollowing-siblingstep selects for its context node. The other axes still use the fallback inlastFunc, which counts the siblings of the candidate node. That count is only the context size on the child axis, solast()is wrong on the remaining axes.Using
employee_examplefrom the tests (line numbers):/empinfo/descendant-or-self::*[last()]//employee[@id=2]/descendant-or-self::*[last()-3]//name/ancestor::*[last()]//name/ancestor-or-self::*[last()]//name/parent::*[last()]//name/self::*[last()]//employee[@id=3]/preceding::*[last()]//employee[@id=3]/preceding-sibling::*[last()]//employee[@id=3]/preceding-sibling::*[last()-1]/root/item/@*[last()](the document inTest_attribute_position)Fix
Following the same pattern as #188,
ancestorQuery,attributeQuery,descendantQueryandprecedingQueryrecord the context node when they start on a new input node, and theircontextSize()counts the nodes their axis selects from it, caching the result per context node.parentQueryandselfQueryselect at most one node per context node, and the predicate is only evaluated for a node that was selected, so their context size is 1.Tests
Test_descendant_last,Test_ancestor_last,Test_parent_last,Test_self_lastandTest_preceding_lastare new, andTest_attribute_positionhas two more cases. Each of them fails onmaster, andgo test ./...andgo vet ./...pass.I also compared
//x/AXIS::*[last()],[last()-1]and[position()=last()]on all twelve axes with lxml over 400 random documents. With this change the only differences left are the order of the results, which #187 covers.Two related cases are not changed here and fail on
mastertoo://b/ancestor::*[@id][last()].(//c)[last()-1]and(//c)[position()=last()].[last()]alone on a group already works throughlastFuncQuery.