Skip to content

Remove unused xpath function text() and processing-instruction()#327

Merged
naitoh merged 2 commits into
ruby:masterfrom
tompng:text_not_a_function
Jun 9, 2026
Merged

Remove unused xpath function text() and processing-instruction()#327
naitoh merged 2 commits into
ruby:masterfrom
tompng:text_not_a_function

Conversation

@tompng

@tompng tompng commented Jun 5, 2026

Copy link
Copy Markdown
Member

Related to #326
Functions must return nodeset or a primitive value. Functions::text() returning an array of string is a bug to be fixed. Although, text() in xpath is resolved as [:child, :text], it's not a function, so Functions::text is unused.

Also removes Functions::processing_instruction. These are node-test, not functions.

Functions must return nodeset or a primitive value. Functions::text() returning an array of string is a bug to be fixed.
Although, `text()` in xpath is resolved as `[:child, :text]`, it's not a function, so Functions::text is unused.
Copilot AI review requested due to automatic review settings June 5, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR removes the Functions::text helper from REXML’s functions module, reducing the set of available XPath-related functions.

Changes:

  • Removed the Functions::text method from lib/rexml/functions.rb.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rexml/functions.rb
Comment on lines 38 to 42
def Functions::context=(value); @@context = value; end

def Functions::text( )
if @@context[:node].node_type == :element
@@context[:node].find_all{|n| n.node_type == :text}.collect{|n| n.value}
elsif @@context[:node].node_type == :text
@@context[:node].value
else
false
end
end

# Returns the last node of the given list of nodes.
def Functions::last( )
@@context[:size]
@tompng tompng changed the title Remove unused xpath function text() Remove unused xpath function text() and processing-instruction() Jun 8, 2026

@naitoh naitoh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@naitoh naitoh merged commit 5815baf into ruby:master Jun 9, 2026
72 of 73 checks passed
@tompng tompng deleted the text_not_a_function branch June 9, 2026 16: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