sparklemotion/nokogiri — pull request #846 by mbklein (2013-02-12 22:49:01+00:00)
Title: JRuby & Builder namespace improvements: Take 2

Having screwed up the commit history on [my previous pull request](https://github.com/sparklemotion/nokogiri/pull/812), I'm trying again.

I thought about splitting this into two separate pull requests, but everything's so intertwined. This change does three things:

1. Add tests for how I *think* Nokogiri is trying to handle namespaces and namespace inheritance – at least tests that are consistent with how most code I've come across expects namespaces to work.
2. Fix the node renaming issues that were causing Xerces to throw NAMESPACE_ERR exceptions in certain (sometimes inconsistent) circumstances.
3. Give Nokogiri::XML::Builder the ability to handle namespace prefixes that won't be formally declared until the first `method_missing` call (e.g., `xml[:foo].bar(:'xmlns:foo' => 'baz')`). The ArgumentError will still be raised if the new prefix isn't declared by the first element encountered.

The libxml C version of Nokogiri still doesn't pass the "expected namespace behavior" tests, but this at least establishes a common baseline for the two.