Skip to content

Added test "It is able to ignore nodes with xmlns attribute set"#13

Open
mirelon wants to merge 3 commits intombklein:masterfrom
mirelon:patch-1
Open

Added test "It is able to ignore nodes with xmlns attribute set"#13
mirelon wants to merge 3 commits intombklein:masterfrom
mirelon:patch-1

Conversation

@mirelon
Copy link
Copy Markdown

@mirelon mirelon commented Feb 5, 2014

When I compare two nodes which have set "xmlns" attribute,
and ignoring them,
they should be equal.

@mirelon
Copy link
Copy Markdown
Author

mirelon commented Feb 5, 2014

This bug may relate to line path = path.gsub(/xmlns:/, ' :') unless Nokogiri.uses_libxml? in https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/node.rb#L153

In the console, when I run:

> Nokogiri::XML('<a xmlns=""></a>').xpath("a")
=> [#<Nokogiri::XML::Element:0x385e name="a">]

but:

> Nokogiri::XML('<a xmlns=""></a>').css("a")
Nokogiri::XML::XPath::SyntaxError: // :a
from nokogiri/XmlXpathContext.java:123:in `evaluate'

The css method is called at https://github.com/mbklein/equivalent-xml/blob/master/lib/equivalent-xml.rb#L188

There is a bug in Nokogiri with nodes with xmlns attribute. Workaround is using search instead of css and allowing xpath queries in ignoring_content_of()
@mirelon
Copy link
Copy Markdown
Author

mirelon commented Feb 6, 2014

It is a nokogiri bug, but it would be nice if ignoring_content_of() allowed also xpath queries. I propose using search() instead of css()

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

Successfully merging this pull request may close these issues.

1 participant