]> Cypherpunks repositories - gostls13.git/commit
encoding/xml: add wildcard support for collecting all attributes
authorRuss Cox <rsc@golang.org>
Thu, 13 Oct 2016 02:58:47 +0000 (22:58 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 18 Oct 2016 12:59:41 +0000 (12:59 +0000)
commitc1a1328c5f004c62b8c08faf0d0d2845e0be5d37
tree3ee7682bbe45110d0040e81231e704c713796ec0
parent0794dce07239fad5845b9c77b50d084f19f7278f
encoding/xml: add wildcard support for collecting all attributes

- Like ",any" for elements, add ",any,attr" for attributes to allow
  a mop-up field that gets any otherwise unmapped attributes.
- Map attributes to fields of type slice by extending the slice,
  just like for elements.
- Allow storing an attribute into an xml.Attr directly, to provide
  a way to record the name.

Combined, these three independent features allow

AllAttrs []Attr `xml:",any,attr"`

to collect all attributes not otherwise spoken for in a particular struct.

Tests based on CL 16292 by Charles Weill.

Fixes #3633.

Change-Id: I2d75817f17ca8752d7df188080a407836af92611
Reviewed-on: https://go-review.googlesource.com/30946
Reviewed-by: Quentin Smith <quentin@golang.org>
src/encoding/xml/marshal.go
src/encoding/xml/marshal_test.go
src/encoding/xml/read.go
src/encoding/xml/typeinfo.go