wolfgangw / backports

Deep inspection of digital cinema packages
27 stars 12 forks source link

dcp_inspect: Nokogiri::XML::Document#collect_namespaces #18

Closed wolfgangw closed 11 years ago

wolfgangw commented 11 years ago

See https://github.com/sparklemotion/nokogiri/issues/885

wolfgangw commented 11 years ago

fdecae6b0395412930ffca1b265a20b768a821bd adds Nokogiri::XML::Document#collect_all_namespaces_href_keys and Nokogiri::XML::Document#collect_all_namespaces_prefix_keys which allow to actually collect all of a document's namespaces -- as opposed to Nokogiri::XML::Document#collect_namespaceswhich succeeds only for specific (if common) documents.

This allows to handle documents correctly which use multiple default namespace definitions (the point of those documents being that e.g. a Signature fragment can come in and go in a minimally obtrusive fashion -- which, while maybe somewhat uncommon, makes perfect sense). See ISDCF Plugfest Fox packages for examples.

A concluding note wrt Nokogiri::XML::Document#collect_namespaces which used to work in dcp_inspect upto (and including) Nokogiri 1.5.5:

The way I used it worked entirely by chance and it fell flat on its nose when Nokogiri 1.5.6 and successive versions returned a different result. Good thing, too.

I do consider Nokogiri::XML::Document#collect_namespaces broken, though, as it will fail to return what its name suggests for a certain kind of (perfectly valid) XML. And that can get ugly.

wolfgangw commented 10 years ago

The previous github auto-comment is nonsense, of course. See https://github.com/wolfgangw/digital_cinema_tools_distribution/issues/18 if you read the https://github.com/wolfgangw/backports/commit/b829636d6ef2fdb7d9e99f43b147947c6316063c commit message