Skip to content

Commit ba923b8

Browse files
committed
encoding/xml: add minimal documentation for XML namespace prefixes in Name
Addresses CL feedback from Adam Shannon.
1 parent 7b80b4d commit ba923b8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/encoding/xml/read.go

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ import (
4848
// the given name (and, optionally, namespace) or else Unmarshal
4949
// returns an error.
5050
//
51+
// - If the XMLName field contains an XML namespace, it may also
52+
// optionally specify a namespace prefix in the form of
53+
// "namespace-URL prefix:name".
54+
//
5155
// - If the XML element has an attribute whose name matches a
5256
// struct field name with an associated tag containing ",attr" or
5357
// the explicit name in a struct field tag of the form "name,attr",

src/encoding/xml/xml.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ func (e *SyntaxError) Error() string {
3636
// with a namespace identifier (Space).
3737
// In tokens returned by [Decoder.Token], the Space identifier
3838
// is given as a canonical URL, not the short prefix used
39-
// in the document being parsed.
39+
// in the document being parsed. If Local is prefixed in
40+
// the form of "prefix:name", this package will attempt to
41+
// use the prefix instead of a fully-qualified namespace URL
42+
// when marshaling.
4043
type Name struct {
4144
Space, Local string
4245
}

0 commit comments

Comments
 (0)