Skip to content

Remove XPath namespace axis handling part which is not working at all#323

Open
tompng wants to merge 1 commit into
ruby:masterfrom
tompng:warn_namespace_axis
Open

Remove XPath namespace axis handling part which is not working at all#323
tompng wants to merge 1 commit into
ruby:masterfrom
tompng:warn_namespace_axis

Conversation

@tompng
Copy link
Copy Markdown
Member

@tompng tompng commented Jun 5, 2026

Namespace axis should return a nodeset of Namespace Node, but Namespace Node class has not even been defined yet.
So namespace axis is completely unimplemented.
Right now, this incomplete code is just getting in the way of refactoring.

REXML::XPath.match(REXML::Document.new('<root/>'), '//*/namespace::*')
# before:
# => in REXML::XPathParser#node_test': undefined method 'raw_node' for an instance of Array (NoMethodError)

# after:
# warning: Namespace axis is not supported in REXML::XPathParser
# => []

Other options:

  • Silently return empty nodeset
  • Always raise error with a message

Copilot AI review requested due to automatic review settings June 5, 2026 12:57
Copy link
Copy Markdown

Copilot AI left a comment

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.

Adds graceful handling for the XPath namespace axis in REXML by preventing exceptions and introducing a regression test.

Changes:

  • Add a test to ensure namespace::* does not raise (regression for NoMethodError).
  • Replace attempted namespace-axis evaluation with a warning and an empty result set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
test/xpath/test_base.rb Adds a regression test around namespace::* behavior.
lib/rexml/xpath_parser.rb Stops attempting to evaluate namespace axis; emits warning and returns empty nodeset.

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

Comment thread lib/rexml/xpath_parser.rb Outdated
Comment on lines +226 to +228
warn 'Namespace axis is not supported in REXML::XPathParser', uplevel: 1
# TODO: We need to create NamespaceNode class to support this feature
nodeset = []
Comment thread lib/rexml/xpath_parser.rb
end
nodesets
end
warn 'Namespace axis is not supported in REXML::XPathParser', uplevel: 1
Comment thread test/xpath/test_base.rb
Comment on lines +251 to +257
def test_axe_namespace_no_error
$VERBOSE, verbose = nil, $VERBOSE
# Although namespace axis is not implemented yet, it should not raise NoMethodError
XPath.match(@@doc, "a/d/c/namespace::*")
ensure
$VERBOSE = verbose
end
Namespace axis should return a nodeset of Namespace Node, but Namespace Node class has not even been defined yet.
@tompng tompng force-pushed the warn_namespace_axis branch from b66d135 to c1a8b09 Compare June 5, 2026 13:16
@tompng tompng mentioned this pull request Jun 5, 2026
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.

2 participants