-
-
Notifications
You must be signed in to change notification settings - Fork 922
Labels
Milestone
Description
The following test case illustrates a bug related to xmlns shadowing on MRI that doesn't happen JRuby. This bug changes the semantic meaning of the output XML.
it 'redeclares xmlns definitions when shadowed' do
doc = Nokogiri::XML::Builder.new do |xml|
xml['dnd'].adventure('xmlns:dnd' => 'http://www.w3.org/dungeons#') do
xml['dnd'].party('xmlns:dnd' => 'http://www.w3.org/dragons#') do
xml['dnd'].members('xmlns:dnd' => 'http://www.w3.org/dragons#') do
xml['dnd'].character('xmlns:dnd' => 'http://www.w3.org/dungeons#') do
xml['dnd'].name('Nigel', 'xmlns:dnd' => 'http://www.w3.org/dungeons#')
end
end
end
end
end.doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
assert_includes(doc, '<dnd:adventure xmlns:dnd="http://www.w3.org/dungeons#">')
assert_includes(doc, '<dnd:party xmlns:dnd="http://www.w3.org/dragons#">')
assert_includes(doc, '<dnd:members>')
# TODO: The MRI (non-JRuby) behavior here is incorrect.
# See: https://github.com/sparklemotion/nokogiri/issues/3458
if Nokogiri.jruby?
assert_includes(doc, '<dnd:character xmlns:dnd="http://www.w3.org/dungeons#">')
else
assert_includes(doc, '<dnd:character>')
end
assert_includes(doc, '<dnd:name>Nigel</dnd:name>')
end
DragonStuff