Skip to content

Default string-length() to the context node - #156

Merged
zhengchun merged 1 commit into
antchfx:masterfrom
LuisFigueroaG:fix/string-length-context-node
Oct 14, 2026
Merged

zhengchun merged 1 commit into
antchfx:masterfrom
LuisFigueroaG:fix/string-length-context-node

Conversation

@LuisFigueroaG

Copy link
Copy Markdown
Contributor

string-length() with no argument fails to compile with "string-length function must have at least one parameter". XPath 1.0 §4.2 makes the argument optional and defaults it to the string-value of the context node, so something like //title[string-length() > 10] should work.

This uses the same self::node() default that normalize-space() already uses, and rejects more than one argument instead. TestInvalidXPath had a case for the no-argument form, so I changed it to the two-argument one, and added context-node cases to Test_func_string_length.

string-length() with no argument failed to compile with "must have at
least one parameter". XPath 1.0 section 4.2 makes the argument
optional and defaults it to the string-value of the context node, so
`//title[string-length() > 10]` should work.

Use the same self::node() default as normalize-space(), and reject more
than one argument instead. The invalid-expression test now checks the
two-argument case.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 84.737% (+0.03%) from 84.707% — LuisFigueroaG:fix/string-length-context-node into antchfx:master

@zhengchun
zhengchun merged commit ccab755 into antchfx:master Oct 14, 2026
3 checks passed
@LuisFigueroaG
LuisFigueroaG deleted the fix/string-length-context-node branch October 20, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants