]> Cypherpunks repositories - gostls13.git/commit
encoding/xml: fix xmlns= behavior
authorRoger Peppe <rogpeppe@gmail.com>
Mon, 29 Jun 2015 11:36:48 +0000 (12:36 +0100)
committerroger peppe <rogpeppe@gmail.com>
Tue, 30 Jun 2015 07:42:37 +0000 (07:42 +0000)
commitbb7e665687d3a9bcbfd7814168a9f6e36d0e632b
tree63582530479c138de9d1cc7d29e3cd101e479a7e
parentab9c25f2de06e74cade453876835b3c1533a39de
encoding/xml: fix xmlns= behavior

When an xmlns="..." attribute was explicitly generated,
it was being ignored because the name space on the
attribute was assumed to have been explicitly set (to the empty
name space) and it's not possible to have an element in the
empty name space when there is a non-empty name space set.

We fix this by recording when a default name space has been
explicitly set and setting the name space of the element to that
so printer.defineNS can do its work correctly.

We do not attempt to add our own xmlns="..." attribute
when one is explicitly set.

We also add tests for EncodeElement, as that's the only way
to attain coverage of some of the changed behaviour.
Some other test coverage is also increased, although
more work remains to be done in this area.

This change was jointly developed with Martin Hilton (mhilton on github).

Fixes #11431.

Change-Id: I7b85e06eea5b18b2c15ec16dcbd92a8e1d6a9a4e
Reviewed-on: https://go-review.googlesource.com/11635
Reviewed-by: Russ Cox <rsc@golang.org>
src/encoding/xml/marshal.go
src/encoding/xml/marshal_test.go
src/encoding/xml/xml.go