defaultStart returns the default start element to use, given the reflect type, field info, and start template.
(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement)
| 657 | // defaultStart returns the default start element to use, |
| 658 | // given the reflect type, field info, and start template. |
| 659 | func defaultStart(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement) StartElement { |
| 660 | var start StartElement |
| 661 | // Precedence for the XML element name is as above, |
| 662 | // except that we do not look inside structs for the first field. |
| 663 | if startTemplate != nil { |
| 664 | start.Name = startTemplate.Name |
| 665 | start.Attr = append(start.Attr, startTemplate.Attr...) |
| 666 | } else if finfo != nil && finfo.name != "" { |
| 667 | start.Name.Local = finfo.name |
| 668 | start.Name.Space = finfo.xmlns |
| 669 | } else if typ.Name() != "" { |
| 670 | start.Name.Local = typ.Name() |
| 671 | } else { |
| 672 | // Must be a pointer to a named type, |
| 673 | // since it has the Marshaler methods. |
| 674 | start.Name.Local = typ.Elem().Name() |
| 675 | } |
| 676 | return start |
| 677 | } |
| 678 | |
| 679 | // marshalInterface marshals a Marshaler interface value. |
| 680 | func (p *printer) marshalInterface(val Marshaler, start StartElement) error { |