Repository navigation
Test existence with exists()/empty() and drop explicit child:: axes - #818
Open
maxonfjvipon wants to merge 1 commit into
Open
maxonfjvipon wants to merge 1 commit into
maxonfjvipon wants to merge 1 commit into
Conversation
… axes count(x) > 0 and count(x) = 0 walk the whole sequence to answer a question the first item settles; exists() and empty() stop there and say what the test means. Spelled-out axes such as child:: are replaced with their abbreviated forms. No change in output is intended.
maxonfjvipon
marked this pull request as ready for review
October 2, 2026 11:55
Author
|
@sydb could you please take a look |
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.
This PR cleans up two old XPath habits across 41 stylesheets: existence tested by counting, and spelled-out axes.
count(x) > 0andcount(x) = 0ask whether a sequence has any items, but they count every item to answer it.exists(x)andempty(x)stop at the first one, and they say what the test means:An explicit
child::is dropped, the abbreviated form being how the rest of the code already writes a child step:Every edit is mechanical, and no change in output is intended.
make testandmake test2pass on this branch, as they do ondev, so no expected output changed (branch run,devrun). I leftprofiles/alone, given the cleanup planned in #452.These were found with xslint, a linter for XSLT. Its fixer made these edits, and I reviewed the diff by hand. It flags more, such as
<xsl:variable><xsl:value-of select="…"/></xsl:variable>where aselectwould do, and I can send follow-up PRs if they'd be welcome.