code: func (p *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error {
  	if val.Kind() == reflect.Ptr {
  		if val.IsNil() {
  			val.Set(reflect.New(val.Type().Elem()))
  		}
  		val = val.Elem()
  	}
  
  	if val.CanInterface() && val.Type().Implements(unmarshalerAttrType) {
  		// This is an unmarshaler with a non-pointer receiver,
  		// so it's likely to be incorrect, but we do what we're told.
  		return val.Interface().(UnmarshalerAttr).UnmarshalXMLAttr(attr)
  	}
  	if val.CanAddr() {
  		pv := val.Addr()
  		if pv.CanInterface() && pv.Type().Implements(unmarshalerAttrType) {
  			return pv.Interface().(UnmarshalerAttr).UnmarshalXMLAttr(attr)
  		}
  	}
  
  	// Not an UnmarshalerAttr; try encoding.TextUnmarshaler.
  	if val.CanInterface() && val.Type().Implements(textUnmarshalerType) {
  		// This is an unmarshaler with a non-pointer receiver,
  		// so it's likely to be incorrect, but we do what we're told.
  		return val.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value))
  	}
  	if val.CanAddr() {
  		pv := val.Addr()
  		if pv.CanInterface() && pv.Type().Implements(textUnmarshalerType) {
  			return pv.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value))
  		}
  	}
  
  	copyValue(val, []byte(attr.Value))
  	return nil
  }
docs: // unmarshalAttr unmarshals a single XML attribute into val.