rails/rails-dom-testing

Unrecognized special XML Namespace

kaspth opened this issue · 1 comments

I'm trying to recognize a xmlns:special. No namespace seems to be defined.

def test_select_with_xml_namespace_attributes
  skip "Nokogiri doesn't recognize this the xmlns:special as a namespace. Perhaps it's because it isn't on the root node?"
  render_html %Q{<link xmlns:special="http://nowhere.com"></link>}
  assert_nothing_raised { assert_select %(special|link) }
end

From https://github.com/kaspth/rails-dom-testing/blob/master/test/selector_assertions_test.rb#L172-L176

Here's the generated syntax tree:

#<Nokogiri::XML::Element:0x3fd7b635a23c name="html" 
  children=[#<Nokogiri::XML::Element:0x3fd7b6385ae0 name="head" 
    children=[#<Nokogiri::XML::Element:0x3fd7b6385694 name="link" attributes=[#<Nokogiri::XML::Attr:0x3fd7b6385590 name="xmlns:special" value="http://nowhere.com">
    ]>
  ]>
]>

//@rafaelfranca, @knu

Summing up @tenderlove's advice. Per the XML spec, a document is invalid if the namespace is not defined on the root node.