From d5764cf4843cf4f071b24deaa167948685cae595 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 4 May 2023 08:05:41 -0700 Subject: [PATCH] encoding/xml: add minimal documentation for XML namespace prefixes in Name Addresses CL feedback from Adam Shannon. --- src/encoding/xml/read.go | 4 ++++ src/encoding/xml/xml.go | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/encoding/xml/read.go b/src/encoding/xml/read.go index d90618f3b6f..838cace42e4 100644 --- a/src/encoding/xml/read.go +++ b/src/encoding/xml/read.go @@ -48,6 +48,10 @@ import ( // the given name (and, optionally, namespace) or else Unmarshal // returns an error. // +// - If the XMLName field contains an XML namespace, it may also +// optionally specify a namespace prefix in the form of +// "namespace-URL prefix:name". +// // - If the XML element has an attribute whose name matches a // struct field name with an associated tag containing ",attr" or // the explicit name in a struct field tag of the form "name,attr", diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go index 14e2e0c9bbe..9aa61b4f658 100644 --- a/src/encoding/xml/xml.go +++ b/src/encoding/xml/xml.go @@ -36,7 +36,10 @@ func (e *SyntaxError) Error() string { // with a namespace identifier (Space). // In tokens returned by [Decoder.Token], the Space identifier // is given as a canonical URL, not the short prefix used -// in the document being parsed. +// in the document being parsed. If Local is prefixed in +// the form of "prefix:name", this package will attempt to +// use the prefix instead of a fully-qualified namespace URL +// when marshaling. type Name struct { Space, Local string }