mirror of
https://github.com/golang/go
synced 2024-11-19 22:04:44 -07:00
encoding/xml: move unexported const out of exported const block
CL 58210 introduced this constant for reasons I don't understand. It should not be in the exported const block, which will pollute godoc output with a "... unexported" notice. Also since we already have a constant named xmlnsPrefix for "xmlns", it is very confusing to also have xmlNamespacePrefix for "xml". If we must have the constant at all, rename it to xmlPrefix. Change-Id: I15f937454d730005816fcd32b1acca703acf1e51 Reviewed-on: https://go-review.googlesource.com/78121 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
c4c3f2a1f2
commit
894869e150
@ -19,8 +19,7 @@ const (
|
|||||||
// Header is a generic XML header suitable for use with the output of Marshal.
|
// Header is a generic XML header suitable for use with the output of Marshal.
|
||||||
// This is not automatically added to any output of this package,
|
// This is not automatically added to any output of this package,
|
||||||
// it is provided as a convenience.
|
// it is provided as a convenience.
|
||||||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
||||||
xmlNamespacePrefix = "xml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Marshal returns the XML encoding of v.
|
// Marshal returns the XML encoding of v.
|
||||||
@ -324,7 +323,7 @@ func (p *printer) createAttrPrefix(url string) string {
|
|||||||
// (The "http://www.w3.org/2000/xmlns/" name space is also predefined as "xmlns",
|
// (The "http://www.w3.org/2000/xmlns/" name space is also predefined as "xmlns",
|
||||||
// but users should not be trying to use that one directly - that's our job.)
|
// but users should not be trying to use that one directly - that's our job.)
|
||||||
if url == xmlURL {
|
if url == xmlURL {
|
||||||
return xmlNamespacePrefix
|
return xmlPrefix
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to define a new name space.
|
// Need to define a new name space.
|
||||||
|
@ -338,6 +338,7 @@ func (d *Decoder) Token() (Token, error) {
|
|||||||
const (
|
const (
|
||||||
xmlURL = "http://www.w3.org/XML/1998/namespace"
|
xmlURL = "http://www.w3.org/XML/1998/namespace"
|
||||||
xmlnsPrefix = "xmlns"
|
xmlnsPrefix = "xmlns"
|
||||||
|
xmlPrefix = "xml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Apply name space translation to name n.
|
// Apply name space translation to name n.
|
||||||
@ -349,7 +350,7 @@ func (d *Decoder) translate(n *Name, isElementName bool) {
|
|||||||
return
|
return
|
||||||
case n.Space == "" && !isElementName:
|
case n.Space == "" && !isElementName:
|
||||||
return
|
return
|
||||||
case n.Space == xmlNamespacePrefix:
|
case n.Space == xmlPrefix:
|
||||||
n.Space = xmlURL
|
n.Space = xmlURL
|
||||||
case n.Space == "" && n.Local == xmlnsPrefix:
|
case n.Space == "" && n.Local == xmlnsPrefix:
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user