1
0
mirror of https://github.com/golang/go synced 2024-11-26 01:07:57 -07:00

encoding/xml: add minimal documentation for XML namespace prefixes in Name

Addresses CL feedback from Adam Shannon.
This commit is contained in:
Randy Reddig 2023-05-04 08:05:41 -07:00 committed by Randy Reddig
parent 235a1c4206
commit d5764cf484
No known key found for this signature in database
2 changed files with 8 additions and 1 deletions

View File

@ -48,6 +48,10 @@ import (
// the given name (and, optionally, namespace) or else Unmarshal // the given name (and, optionally, namespace) or else Unmarshal
// returns an error. // 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 // - If the XML element has an attribute whose name matches a
// struct field name with an associated tag containing ",attr" or // struct field name with an associated tag containing ",attr" or
// the explicit name in a struct field tag of the form "name,attr", // the explicit name in a struct field tag of the form "name,attr",

View File

@ -36,7 +36,10 @@ func (e *SyntaxError) Error() string {
// with a namespace identifier (Space). // with a namespace identifier (Space).
// In tokens returned by [Decoder.Token], the Space identifier // In tokens returned by [Decoder.Token], the Space identifier
// is given as a canonical URL, not the short prefix used // 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 { type Name struct {
Space, Local string Space, Local string
} }