|
encoding/xml: namespace inheritance and prefixes on attributes
This is a fix for Issue 3526, though I'd like to write more tests if
reviewers think I'm on the right track.
The central idea is that each XML element has a context which
includes a mapping between prefixes and URIs, as well as the
namespace of that element. This allows attributes to have different
namespaces from their parent elements, as well as the canonical "HTML
table and coffee table" example from
http://www.w3.org/TR/REC-xml-names/.
Problems with this approach:
1. We can't add a new Prefix field to xml.Name, because it breaks
source compatibility.
2. That means there's no good way to load namespace context at
runtime, before calling Marshal() or Unmarshal(). This is an
important bit of functionality, for cases when the user wants to
start in the middle of a document. It should be possible to work
around by creating a fake top-level element with the appropriate
context, but that seems hackish.
3.There's no way to add a new prefix to this element strictly for the
benefit of its child elements.
I'll expand on these a bit on golang-nuts.
|