Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XPath queries for namespaces are broken on JRuby #764

Closed
flavorjones opened this issue Sep 20, 2012 · 4 comments
Closed

XPath queries for namespaces are broken on JRuby #764

flavorjones opened this issue Sep 20, 2012 · 4 comments

Comments

@flavorjones
Copy link
Member

Discovered while working on #761 (test breakage on the issue-761 branch). Getting the following exception:

# NokogiriHelpers.java:105:in `getCachedNodeOrCreate': java.lang.ClassCastException: nokogiri.XmlNamespace cannot be cast to nokogiri.XmlDocument

I've found this behavior is different in the two following examples.

Example 1:

xml = <<EOXML
<root xmlns:foo="http://google.com/">
  <foo:node>hello</foo:node>
</root>
EOXML

doc = Nokogiri::XML xml
puts doc.xpath("//namespace::*").inspect # first time is OK
puts doc.xpath("//namespace::*").inspect # second time raises exception

Example 2:

xml = <<EOXML
<base>
  <root xmlns:foo="http://google.com/">
  </root>
</base>
EOXML

doc = Nokogiri::XML xml
puts doc.xpath("//namespace::*").inspect # raises exception
@soulcutter
Copy link
Contributor

No test case included with the fix?

@jvshahid
Copy link
Member

there was a failing test (test_collect_namespaces) on the issue-761 branch.

@soulcutter
Copy link
Contributor

Awesome. I was going to circle back around this evening and add a test case, but you are on top of it! Apologies if I came across as critical.

@jvshahid
Copy link
Member

No worries. Critical is better than sloppy. Thanks for following up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants