aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/marshal.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/xml/marshal.go')
-rw-r--r--src/encoding/xml/marshal.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go
index 07b6042da8..0c3cc0dc36 100644
--- a/src/encoding/xml/marshal.go
+++ b/src/encoding/xml/marshal.go
@@ -543,6 +543,11 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat
}
}
+ // If a name was found, namespace is overridden with an empty space
+ if tinfo.xmlname != nil && start.Name.Space == "" &&
+ len(p.tags) != 0 && p.tags[len(p.tags)-1].Space != "" {
+ start.Attr = append(start.Attr, Attr{Name{"", xmlnsPrefix}, ""})
+ }
if err := p.writeStart(&start); err != nil {
return err
}