-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
Allow attributes without namespace on jRuby
#2677
Comments
Hi! I've reproduced what you're seeing, and just to share my analysis: #! /usr/bin/env ruby
require "nokogiri"
xml = <<~XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<bookViews>
<workbookView r:xWindow="360" yWindow="15" windowWidth="20955"
windowHeight="9720" activeTab="0"/>
</bookViews>
</workbook>
XML
doc = Nokogiri::XML(xml, &:strict)
sheet = doc.at_xpath('xmlns:workbook/xmlns:bookViews/xmlns:workbookView')
puts sheet.attribute('xWindow').inspect On CRuby, this outputs something like:
but on JRuby, the attribute lookup fails and so the script prints This appears to be a bug, and I'm honestly surprised that we don't have tests for the desired behavior. I'll dig in! |
OK, this isn't a simple fix, unfortunately, because the JRuby implementation is handling attributes inconsistently, sometimes treating local names as prefixed names, and vice versa, in a few different places. I'll work on it, but it may not be fixed immediately. |
See #2679 for the work-in-progress. Maybe this branch is good enough for you? If so, please let me know and I may be able to get that partial fix into the next release. |
Discussed in #2675
Originally posted by ShockwaveNN October 20, 2022
Hi, trying to port one of my library for parsing
ooxml
to jruby and I got a problemI got this XML
And simplified ruby code to parse it:
On mruby this output 360
But on jruby it just crash with:
If I change puts to
It works correctly on both rubies
I understand that mruby and jruby uses different XML parser
Is there any option to jruby to make parsing of such attributes same as on jruby or proper way will be to fix my codebase by adding
r:
namespace?The text was updated successfully, but these errors were encountered: