Skip to content

Support string-length() XPath function without an argument#337

Open
SAY-5 wants to merge 1 commit into
ruby:masterfrom
SAY-5:fix-string-length-no-argument
Open

Support string-length() XPath function without an argument#337
SAY-5 wants to merge 1 commit into
ruby:masterfrom
SAY-5:fix-string-length-no-argument

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 17, 2026

Copy link
Copy Markdown

Per XPath 1.0, string-length() defaults to the string-value of the context node when called without an argument, but Functions.string_length required a positional argument and raised ArgumentError.

REXML::XPath.match(REXML::Document.new('<root><item>123</item><item>1234</item><item>12345</item></root>'), '//item[string-length()=4]')
# before: wrong number of arguments (given 0, expected 1) (ArgumentError)
# after:  matches the <item>1234</item> element

Defaults the argument to @context[:node] to match string and normalize_space.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

1 participant