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 returns inconsistent result set on cloned document with namespaces and attributes. #1034

Closed
jcoyne opened this issue Jan 23, 2014 · 3 comments

Comments

@jcoyne
Copy link

jcoyne commented Jan 23, 2014

When I run this code in Jruby 1.7.9

require 'nokogiri'
builder = Nokogiri::XML::Builder.new do |xml|
    xml.mods("xmlns"=>"http://www.loc.gov/mods/v3") {
         xml.name(:type=>"personal") {
           xml.namePart()
         }
       }
end
ng_xml = builder.doc
new_doc = Nokogiri::XML(ng_xml.to_s)
xpath = '//oxns:name[@type="personal"]'
namespaces = {'oxns' => "http://www.loc.gov/mods/v3"}
original_result = ng_xml.xpath(xpath, namespaces)
clone_result = new_doc.xpath(xpath, namespaces)
puts "clone length #{clone_result.length}"
puts "original length #{original_result.length}"
puts clone_result.length == original_result.length ? "Success" : "Failure"

the output is:

clone length 1
original length 0
Failure

I would expect clone length and original length to both be 1.

@jcoyne
Copy link
Author

jcoyne commented Jan 23, 2014

When this is run in Ruby 2.1.0 (MRI), then it works as expected.

@mbklein
Copy link
Contributor

mbklein commented Jan 24, 2014

I think I know where this is coming from. I'll take a look when I get a chance.

@yokolet
Copy link
Member

yokolet commented Apr 15, 2014

Hi,
This bug has been fixed at some point, probably when the pull request has been merged. I tried the given code snippet and got "Success". (on master)

I'm going to close this issue. If you still have the problem, feel free to reopen.

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

No branches or pull requests

3 participants