Constantin Konstantinidis has uploaded this change for review.
encoding/xml : fix duplication of namespace tags by encoder
A tag prefix identifies the name space of the tag (https://www.w3.org/TR/xml/#sec-starttags)
and not the default name space like xmlns="...". Writing the prefix is incorrect when it is
bound to a name space using the standard xmlns:prefix="..." attribute.
This fix skips this print.
Consequences are
- duplication is avoided in line with name space standard in reference.
- the _xmlns declaration does not appear anymore
To keep the previous behaviour, the prefix is printed in all other cases. Token now always
produces well-formed XML except when the explicit name space collides with the prefix.
Made prefix handling "xmlns="space" xmlns:_xmlns="xmlns" _..." has be removed in all wants of tests.
- invalid XML in tests have been reduced because many attributes/name spaces are not duplicated.
- explicit namespace and a colliding prefix still produced not well-formed XML because of attributes
like xmlns:x="x" which are added by existing exception handling.
- empty name space declaration is not correctly handled as before. A separate fix is available.
Fixes #7535
Change-Id: If89f721f5d2cf123c901b4293365c429209162a3
---
M src/encoding/xml/marshal.go
M src/encoding/xml/marshal_test.go
M src/encoding/xml/xml_test.go
3 files changed, 116 insertions(+), 54 deletions(-)
diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go
index d393d06..c331dae 100644
--- a/src/encoding/xml/marshal.go
+++ b/src/encoding/xml/marshal.go
@@ -691,10 +691,24 @@
p.WriteByte('<')
p.WriteString(start.Name.Local)
- if start.Name.Space != "" {
- p.WriteString(` xmlns="`)
- p.EscapeString(start.Name.Space)
- p.WriteByte('"')
+ if start.Name.Space != "" { // tag starts with <.Space:.Local
+ // The tag prefix is not the default name space and it is a mistake to print it if not bound by an attribute
+ dontPrintTagSpace := false
+ for _, attr := range start.Attr {
+ // If translated, i.e. value found, it contains the URI, i.e. the Value of the attribute.
+ // This skewed logic requires to compare .Name.Space to attr.Value
+ // Verifying a proper definition requires to take this "translation" into account !
+ if start.Name.Space == attr.Value && attr.Name.Space == xmlnsPrefix && attr.Name.Local != "" {
+ // if the prefix is bound, the attr is xlmns:prefix=.Value and tag namespace will be defined
+ dontPrintTagSpace = true
+ break
+ }
+ }
+ if !dontPrintTagSpace {
+ p.WriteString(` xmlns="`)
+ p.EscapeString(start.Name.Space)
+ p.WriteByte('"')
+ }
}
// Attributes
@@ -704,8 +718,11 @@
continue
}
p.WriteByte(' ')
- if name.Space != "" {
- p.WriteString(p.createAttrPrefix(name.Space))
+ if name.Space == xmlnsPrefix { // defining prefix name.Local xmlns:{.Local}={.Value}
+ p.WriteString(xmlnsPrefix)
+ p.WriteByte(':')
+ } else if name.Space != "" { // non-standard name space {.Space}:{.Local}={.Value}
+ p.WriteString(p.createAttrPrefix(name.Space)) // name.Space is not a prefix
p.WriteByte(':')
}
p.WriteString(name.Local)
diff --git a/src/encoding/xml/marshal_test.go b/src/encoding/xml/marshal_test.go
index a0ccf44..b3619c1 100644
--- a/src/encoding/xml/marshal_test.go
+++ b/src/encoding/xml/marshal_test.go
@@ -2045,102 +2045,104 @@
err: "xml: end tag </foo> in namespace another does not match start tag <foo> in namespace space",
want: `<foo xmlns="space">`,
}, {
- desc: "start element with explicit namespace",
+ desc: "start element with explicit namespace", // outside namespace standard
toks: []Token{
StartElement{Name{"space", "local"}, []Attr{
{Name{"xmlns", "x"}, "space"},
{Name{"space", "foo"}, "value"},
}},
},
- want: `<local xmlns="space" xmlns:_xmlns="xmlns" _xmlns:x="space" xmlns:space="space" space:foo="value">`,
+ want: `<local xmlns:x="space" xmlns:space="space" space:foo="value">`,
}, {
desc: "start element with explicit namespace and colliding prefix",
toks: []Token{
StartElement{Name{"space", "local"}, []Attr{
- {Name{"xmlns", "x"}, "space"},
- {Name{"space", "foo"}, "value"},
- {Name{"x", "bar"}, "other"},
+ {Name{"xmlns", "x"}, "space"}, // xmlns:x="space"
+ {Name{"space", "foo"}, "value"}, // space:foo="value"
+ {Name{"x", "bar"}, "other"}, // x:bar="other"
}},
},
- want: `<local xmlns="space" xmlns:_xmlns="xmlns" _xmlns:x="space" xmlns:space="space" space:foo="value" xmlns:x="x" x:bar="other">`,
+ // Removed version was not well-formed as x is bound to "space" and to "x"
+ want: `<local xmlns:x="space" xmlns:space="space" space:foo="value" xmlns:x="x" x:bar="other">`,
}, {
desc: "start element using previously defined namespace",
toks: []Token{
StartElement{Name{"", "local"}, []Attr{
- {Name{"xmlns", "x"}, "space"},
+ {Name{"xmlns", "x"}, "space"}, // xmlns:x="space"
}},
StartElement{Name{"space", "foo"}, []Attr{
- {Name{"space", "x"}, "y"},
+ {Name{"space", "x"}, "y"}, // space:x="y"
}},
},
- want: `<local xmlns:_xmlns="xmlns" _xmlns:x="space"><foo xmlns="space" xmlns:space="space" space:x="y">`,
+ // The well-formed prefix is the only one appearing
+ want: `<local xmlns:x="space"><foo xmlns="space" xmlns:space="space" space:x="y">`,
}, {
desc: "nested name space with same prefix",
toks: []Token{
StartElement{Name{"", "foo"}, []Attr{
- {Name{"xmlns", "x"}, "space1"},
+ {Name{"xmlns", "x"}, "space1"}, // xmlns:x="space1"
}},
StartElement{Name{"", "foo"}, []Attr{
- {Name{"xmlns", "x"}, "space2"},
+ {Name{"xmlns", "x"}, "space2"}, // xmlns:x="space2"
}},
StartElement{Name{"", "foo"}, []Attr{
- {Name{"space1", "a"}, "space1 value"},
- {Name{"space2", "b"}, "space2 value"},
+ {Name{"space1", "a"}, "space1 value"}, // space1:a="space1 value"
+ {Name{"space2", "b"}, "space2 value"}, // space2:b="space2 value"
}},
EndElement{Name{"", "foo"}},
EndElement{Name{"", "foo"}},
StartElement{Name{"", "foo"}, []Attr{
- {Name{"space1", "a"}, "space1 value"},
- {Name{"space2", "b"}, "space2 value"},
+ {Name{"space1", "a"}, "space1 value"}, // space1:a="space1 value"
+ {Name{"space2", "b"}, "space2 value"}, // space2:b="space2 value"
}},
},
- want: `<foo xmlns:_xmlns="xmlns" _xmlns:x="space1"><foo _xmlns:x="space2"><foo xmlns:space1="space1" space1:a="space1 value" xmlns:space2="space2" space2:b="space2 value"></foo></foo><foo xmlns:space1="space1" space1:a="space1 value" xmlns:space2="space2" space2:b="space2 value">`,
+ want: `<foo xmlns:x="space1"><foo xmlns:x="space2"><foo xmlns:space1="space1" space1:a="space1 value" xmlns:space2="space2" space2:b="space2 value"></foo></foo><foo xmlns:space1="space1" space1:a="space1 value" xmlns:space2="space2" space2:b="space2 value">`,
}, {
desc: "start element defining several prefixes for the same name space",
toks: []Token{
StartElement{Name{"space", "foo"}, []Attr{
- {Name{"xmlns", "a"}, "space"},
- {Name{"xmlns", "b"}, "space"},
- {Name{"space", "x"}, "value"},
+ {Name{"xmlns", "a"}, "space"}, // xmlns:a="space"
+ {Name{"xmlns", "b"}, "space"}, // xmlns:b="space"
+ {Name{"space", "x"}, "value"}, // space:x="value"
}},
},
- want: `<foo xmlns="space" xmlns:_xmlns="xmlns" _xmlns:a="space" _xmlns:b="space" xmlns:space="space" space:x="value">`,
+ want: `<foo xmlns:a="space" xmlns:b="space" xmlns:space="space" space:x="value">`,
}, {
desc: "nested element redefines name space",
toks: []Token{
StartElement{Name{"", "foo"}, []Attr{
- {Name{"xmlns", "x"}, "space"},
+ {Name{"xmlns", "x"}, "space"}, // xmlns:x="space"
}},
StartElement{Name{"space", "foo"}, []Attr{
- {Name{"xmlns", "y"}, "space"},
- {Name{"space", "a"}, "value"},
+ {Name{"xmlns", "y"}, "space"}, // xmlns:y="space"
+ {Name{"space", "a"}, "value"}, // space:a="value"
}},
- },
- want: `<foo xmlns:_xmlns="xmlns" _xmlns:x="space"><foo xmlns="space" _xmlns:y="space" xmlns:space="space" space:a="value">`,
+ }, // space="space" oddity still appears
+ want: `<foo xmlns:x="space"><foo xmlns:y="space" xmlns:space="space" space:a="value">`,
}, {
desc: "nested element creates alias for default name space",
toks: []Token{
- StartElement{Name{"space", "foo"}, []Attr{
- {Name{"", "xmlns"}, "space"},
+ StartElement{Name{"space", "foo"}, []Attr{ // <space:foo
+ {Name{"", "xmlns"}, "space"}, // xmlns="space"
}},
- StartElement{Name{"space", "foo"}, []Attr{
- {Name{"xmlns", "y"}, "space"},
- {Name{"space", "a"}, "value"},
+ StartElement{Name{"space", "foo"}, []Attr{ // <space:foo
+ {Name{"xmlns", "y"}, "space"}, // xmlns:y="space"
+ {Name{"space", "a"}, "value"}, // space:a="value"
}},
- },
- want: `<foo xmlns="space" xmlns="space"><foo xmlns="space" xmlns:_xmlns="xmlns" _xmlns:y="space" xmlns:space="space" space:a="value">`,
+ }, // Invalid duplication is kept
+ want: `<foo xmlns="space" xmlns="space"><foo xmlns:y="space" xmlns:space="space" space:a="value">`,
}, {
desc: "nested element defines default name space with existing prefix",
toks: []Token{
StartElement{Name{"", "foo"}, []Attr{
- {Name{"xmlns", "x"}, "space"},
+ {Name{"xmlns", "x"}, "space"}, // xmlns:x="space"
}},
- StartElement{Name{"space", "foo"}, []Attr{
- {Name{"", "xmlns"}, "space"},
- {Name{"space", "a"}, "value"},
+ StartElement{Name{"space", "foo"}, []Attr{ // <space:foo
+ {Name{"", "xmlns"}, "space"}, // xlmns="space"
+ {Name{"space", "a"}, "value"}, // space:a="value"
}},
},
- want: `<foo xmlns:_xmlns="xmlns" _xmlns:x="space"><foo xmlns="space" xmlns="space" xmlns:space="space" space:a="value">`,
+ want: `<foo xmlns:x="space"><foo xmlns="space" xmlns="space" xmlns:space="space" space:a="value">`,
}, {
desc: "nested element uses empty attribute name space when default ns defined",
toks: []Token{
@@ -2177,13 +2179,13 @@
},
want: `<foo xmlns="space" xml:xmlns="space">`,
}, {
- desc: "empty name space declaration is ignored",
+ desc: "empty name space declaration is ignored", // #8068
toks: []Token{
StartElement{Name{"", "foo"}, []Attr{
- {Name{"xmlns", "foo"}, ""},
+ {Name{"xmlns", "foo"}, ""}, // xmlns:foo=""
}},
},
- want: `<foo xmlns:_xmlns="xmlns" _xmlns:foo="">`,
+ want: `<foo xmlns:foo="">`, // not well-formed
}, {
desc: "attribute with no name is ignored",
toks: []Token{
@@ -2234,16 +2236,16 @@
}, {
desc: "default name space should not be used by attributes",
toks: []Token{
- StartElement{Name{"space", "foo"}, []Attr{
- {Name{"", "xmlns"}, "space"},
- {Name{"xmlns", "bar"}, "space"},
- {Name{"space", "baz"}, "foo"},
+ StartElement{Name{"space", "foo"}, []Attr{ // <space:foo
+ {Name{"", "xmlns"}, "space"}, // xmlns="space"
+ {Name{"xmlns", "bar"}, "space"}, // xmlns:bar="space"
+ {Name{"space", "baz"}, "foo"}, // space:baz="foo"
}},
- StartElement{Name{"space", "baz"}, nil},
- EndElement{Name{"space", "baz"}},
- EndElement{Name{"space", "foo"}},
+ StartElement{Name{"space", "baz"}, nil}, // <space:baz
+ EndElement{Name{"space", "baz"}}, // space:baz>
+ EndElement{Name{"space", "foo"}}, // space:foo>
},
- want: `<foo xmlns="space" xmlns="space" xmlns:_xmlns="xmlns" _xmlns:bar="space" xmlns:space="space" space:baz="foo"><baz xmlns="space"></baz></foo>`,
+ want: `<foo xmlns="space" xmlns:bar="space" xmlns:space="space" space:baz="foo"><baz xmlns="space"></baz></foo>`,
}, {
desc: "default name space not used by attributes, not explicitly defined",
toks: []Token{
diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go
index 7a3511d..235c0c7 100644
--- a/src/encoding/xml/xml_test.go
+++ b/src/encoding/xml/xml_test.go
@@ -745,6 +745,49 @@
}
}
+func TestIssue7535(t *testing.T) {
+ source := `<ex:element xmlns:ex="http://example.com/schema"></ex:element>`
+ result := `<element xmlns:ex="http://example.com/schema"></element>`
+ // The prefix of a tag is the default namespace. A prefix is never a default namespace.
+ //source := `<element xmlns="http://example.com/schema" xmlns:_xmlns="xmlns" _xmlns:ex="http://example.com/schema"></element>`
+ // Issue : the prefix of the tag "ex" is defined using xmlns and by default Token writes
+ // the namespace of the prefix because it is in the tag name
+ // But in a well-formed xml, it is useless as the prefix is bound and recorded as an attribute
+ in := bytes.NewBufferString(source)
+ var errl error
+
+ for i := 0; i < 2; i++ {
+ out := &bytes.Buffer{}
+ d := NewDecoder(in)
+ e := NewEncoder(out)
+ errl = nil
+ for errl == nil {
+ t, err := d.Token()
+ if err != nil {
+ if err == io.EOF {
+ errl = err
+ //continue
+ //break
+ } else {
+ fmt.Errorf("failed:%s", err)
+ }
+ //return
+ } else { // err is nil
+ e.EncodeToken(t)
+ }
+ }
+ e.Flush()
+ in = out
+ if in.String() != result {
+ t.Errorf("duplicating namespace : got %s, want %s \n", in.String(), result)
+ }
+ }
+
+ if errl != nil && errl != io.EOF {
+ t.Errorf("%s \n: duplicating namespace : got error %v, want no fail \n", source, errl)
+ }
+}
+
func TestIssue11405(t *testing.T) {
testCases := []string{
"<root>",
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Thanks, but note that the issue says it is blocked on #13400, which collects together a bunch of XML namespace issues. I don't think it's a good idea to tackle them piecemeal, as in this CL. I think they should be tackled with a coherent overall strategy.
2 comments:
File src/encoding/xml/marshal.go:
Patch Set #1, Line 695: // The tag prefix is not the default name space and it is a mistake to print it if not bound by an attribute
In general, when comments are complete sentences, use proper punctuation, namely a trailing period.
File src/encoding/xml/xml_test.go:
Patch Set #1, Line 756: in := bytes.NewBufferString(source)
Use strings.NewReader.
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Constantin Konstantinidis uploaded patch set #2 to this change.
encoding/xml : fix duplication of namespace tags by encoder
A tag prefix identifies the name space of the tag (https://www.w3.org/TR/xml/#sec-starttags)
and not the default name space like xmlns="...". Writing the prefix is incorrect when it is
bound to a name space using the standard xmlns:prefix="..." attribute.
This fix skips this print.
Consequences are
- duplication is avoided in line with name space standard in reference.
- the _xmlns declaration does not appear anymore.
To keep the previous behaviour, the prefix is printed in all other cases. Token now always
produces well-formed XML except when the explicit name space collides with the prefix.
Made prefix handling "xmlns="space" xmlns:_xmlns="xmlns" _..." has be removed in all wants of tests.
- invalid XML in tests have been reduced because many attributes/name spaces are not duplicated.
- explicit namespace and a colliding prefix still produced not well-formed XML because of attributes
like xmlns:x="x" which are added by existing exception handling.
- empty name space declaration is not correctly handled as before. A separate fix is available.
Fixes #7535
Change-Id: If89f721f5d2cf123c901b4293365c429209162a3
---
M src/encoding/xml/marshal.go
M src/encoding/xml/marshal_test.go
M src/encoding/xml/xml_test.go
3 files changed, 113 insertions(+), 54 deletions(-)
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Patch Set 1:
(2 comments)
Thanks, but note that the issue says it is blocked on #13400, which collects together a bunch of XML namespace issues. I don't think it's a good idea to tackle them piecemeal, as in this CL. I think they should be tackled with a coherent overall strategy.
Thanks for your reply.
I updated the patch according to comments.
I also submitted the situation of #13400 on github.
I started working on the go lang project a few weeks ago and I selected the encoder/xml for various reasons including the apparent inactivity. Generally speaking, the strategy was to enforce the XML Namespace standard.
Fixes have been submitted in accordance. They are mostly independent from each other. If a fix solves several issues, it has been commented accordingly.
Next step like #7113 will be easier with all fixes merged as it involves the usage of an empty name space to override the default which is foreseen in the standard.
Technically, the current implementation is not using the namespace prefixes everywhere but uses a "translate" func to override them with a value. This is very cumbersome from a logic perspective. Removing this "translate" func would allow to remove the emulated stack logic which is not suited to search for the active namespace.
Constantin Konstantinidis uploaded patch set #3 to this change.
encoding/xml : fix duplication of namespace tags by encoder
A tag prefix identifies the name space of the tag (https://www.w3.org/TR/xml/#sec-starttags)
and not the default name space like xmlns="...". Writing the prefix is incorrect when it is
bound to a name space using the standard xmlns:prefix="..." attribute.
This fix skips this print.
Consequences are
- duplication is avoided in line with name space standard in reference.
- the _xmlns declaration does not appear anymore.
To keep the previous behaviour, the prefix is printed in all other cases. Token now always
produces well-formed XML except when the explicit name space collides with the prefix.
Made prefix handling "xmlns="space" xmlns:_xmlns="xmlns" _..." has be removed in all wants of tests.
- invalid XML in tests have been reduced because many attributes/name spaces are not duplicated.
- explicit namespace and a colliding prefix still produced not well-formed XML because of attributes
like xmlns:x="x" which are added by existing exception handling.
- empty name space declaration is not correctly handled as before. A separate fix is available.
Fixes #7535
Change-Id: If89f721f5d2cf123c901b4293365c429209162a3
---
M src/encoding/xml/marshal.go
M src/encoding/xml/marshal_test.go
M src/encoding/xml/xml_test.go
3 files changed, 113 insertions(+), 54 deletions(-)
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Constantin Konstantinidis uploaded patch set #4 to this change.
encoding/xml: fix duplication of namespace tags by encoder
A tag prefix identifies the name space of the tag
(https://www.w3.org/TR/xml/#sec-starttags)
and not the default name space like xmlns="..." unless a token is passed with a Space set.
Writing the prefix is incorrect when it is not bound to a name space using the standard
xmlns:prefix="..." attribute. This fix skips this print.
Consequences are
- duplication is avoided in line with name space standard in reference.
- the _xmlns declaration does not appear anymore as xmlns is recognized as reserved.
To keep the previous behaviour, the prefix is printed in all other cases. Token now always
produces well-formed XML except when the explicit name space collides with the prefix.
Made prefix handling "xmlns="space" xmlns:_xmlns="xmlns" _..." has be removed in
all wants of tests.
- invalid XML in tests have been reduced because many attributes/name spaces are
not duplicated.
- explicit namespace and a colliding prefix still produced not well-formed XML because
of attributes like xmlns:x="x" which are added by existing exception handling.
- empty name space declaration is not correctly handled as before.
A separate fix is available.
Fixes #7535
Change-Id: If89f721f5d2cf123c901b4293365c429209162a3
---
M src/encoding/xml/marshal.go
M src/encoding/xml/marshal_test.go
M src/encoding/xml/xml_test.go
3 files changed, 113 insertions(+), 54 deletions(-)
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
I discussed these XML changes with Russ and others and it sounds like we want to prioritize these (and JSON) for after Go 1.11 and after vgo. We just didn't have the review bandwidth in this area this cycle and can't accept the risk of regressions this late in Go 1.11. I'm going to mark this for Go 1.12 for now. Sorry.
Constantin Konstantinidis uploaded patch set #6 to this change.
encoding/xml: recognize xmlns as reserved
xmlns is reserved to indicate name space (https://www.w3.org/TR/REC-xml-names/#ns-decl).
When present, it is printed as is instead of attempting to create a prefix.
Default namespace is now printed as last attribute when no xmlns attribute was found.
Fixes #7535
Change-Id: If89f721f5d2cf123c901b4293365c429209162a3
---
M src/encoding/xml/atom_test.go
M src/encoding/xml/marshal.go
M src/encoding/xml/marshal_test.go
M src/encoding/xml/xml_test.go
4 files changed, 88 insertions(+), 29 deletions(-)
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Ian Lance Taylor.
3 comments:
Patchset:
CL is rebased and clutter is removed.
It is a bit bigger than expected as the xmlns attribute prints last in some cases.
File src/encoding/xml/marshal.go:
Patch Set #1, Line 695: // The tag prefix is not the default name space and it is a mistake to print it if not bound by an attribute
In general, when comments are complete sentences, use proper punctuation, namely a trailing period.
Done
File src/encoding/xml/xml_test.go:
Patch Set #1, Line 756: in := bytes.NewBufferString(source)
Use strings.NewReader.
Done
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Constantin Konstantinidis.
5 comments:
File src/encoding/xml/marshal_test.go:
Patch Set #6, Line 1256: ExpectXML: `<outer int="10" xmlns="testns"></outer>`,
I'm afraid that if we make this change we will break a lot of golden files that are otherwise perfectly fine. Can we keep the xmlns in the same place by scanning ahead to see whether we should emit it?
File src/encoding/xml/xml_test.go:
Patch Set #6, Line 925: for i := 0; i < 4; i++ {
Why do this 4 times?
Patch Set #6, Line 926: out := &bytes.Buffer{}
Use strings.Builder.
Patch Set #6, Line 940: if err != nil {
Testing err here doesn't make sense, the previous line set err1.
Patch Set #6, Line 950: t.Errorf("duplicate namespace : got %s, want %s \n", out.String(), result)
No need for a newline in t.Errorf.
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Constantin Konstantinidis.
Constantin Konstantinidis uploaded patch set #7 to this change.
encoding/xml: recognize xmlns as reserved
xmlns is reserved to indicate name space (https://www.w3.org/TR/REC-xml-names/#ns-decl). This CL adds detection of the prefix to avoid its duplication.
Fixes #7535
Change-Id: If89f721f5d2cf123c901b4293365c429209162a3
---
M src/encoding/xml/marshal.go
M src/encoding/xml/marshal_test.go
2 files changed, 26 insertions(+), 10 deletions(-)
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Ian Lance Taylor.
6 comments:
Patchset:
Only duplication of xmlns is removed by this CL.
File src/encoding/xml/marshal_test.go:
Patch Set #6, Line 1256: ExpectXML: `<outer int="10" xmlns="testns"></outer>`,
I'm afraid that if we make this change we will break a lot of golden files that are otherwise perfec […]
All attributes keep their place. This CL does not attempt anymore to remove duplication of name space (go.dev/issues/42807) when they are forced by EncodeToken.
File src/encoding/xml/xml_test.go:
Patch Set #6, Line 925: for i := 0; i < 4; i++ {
Why do this 4 times?
Test is removed from CL. It is not adding anything to existing tests where the duplication of xmlns is removed.
Patch Set #6, Line 926: out := &bytes.Buffer{}
Use strings.Builder.
Ack
Patch Set #6, Line 940: if err != nil {
Testing err here doesn't make sense, the previous line set err1.
Ack
Patch Set #6, Line 950: t.Errorf("duplicate namespace : got %s, want %s \n", out.String(), result)
No need for a newline in t.Errorf.
Ack
To view, visit change 107755. To unsubscribe, or for help writing mail filters, visit settings.