func (bagc BiddableAdGroupCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Attr = append(
		start.Attr,
		xml.Attr{
			xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
			"BiddableAdGroupCriterion",
		},
	)
	e.EncodeToken(start)
	e.EncodeElement(&bagc.AdGroupId, xml.StartElement{Name: xml.Name{"", "adGroupId"}})
	criterionMarshalXML(bagc.Criterion, e)

	if bagc.UserStatus != "" {
		e.EncodeElement(&bagc.UserStatus, xml.StartElement{Name: xml.Name{"", "userStatus"}})
	}
	if bagc.DestinationUrl != "" {
		e.EncodeElement(&bagc.DestinationUrl, xml.StartElement{Name: xml.Name{"", "destinationUrl"}})
	}
	e.EncodeElement(&bagc.BiddingStrategyConfiguration, xml.StartElement{Name: xml.Name{"", "biddingStrategyConfiguration"}})
	if bagc.BidModifier != 0 {
		e.EncodeElement(&bagc.BidModifier, xml.StartElement{Name: xml.Name{"", "bidModifier"}})
	}
	e.EncodeToken(start.End())
	return nil
}
示例#2
0
// MarshalXML implementation on JobErrorDateTime to skip "zero" time values
func (jdt JobErrorDateTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if jdt.IsZero() {
		return nil
	}
	e.EncodeElement(jdt.Time, start)
	return nil
}
func (n CharData) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	return e.EncodeElement(struct {
		S string `xml:",innerxml"`
	}{
		S: "<![CDATA[" + string(n) + "]]>",
	}, start)
}
示例#4
0
文件: datetime.go 项目: mihteh/types
// MarshalXML реализует интерфейс xml.Marshaler для объекта NullDate
// сериализация происходит с учётом шаблона, заданного в свойстве Layout
func (d NullDate) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error {
	if !d.Valid {
		return encoder.EncodeElement(nil, start)
	}
	d.fixLayout()
	return encoder.EncodeElement(d.String(), start)
}
示例#5
0
func (n NominalType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if n == Nominal {
		return e.EncodeElement("NOMINAL", start)
	} else {
		return e.EncodeElement("CALCULATED", start)
	}
}
示例#6
0
// MarshalXML marshals NullInts greater than zero to XML. Otherwise nothing is
// marshaled.
func (n NullInt) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if n.Valid {
		e.EncodeElement(n.Int, start)
	}

	return nil
}
示例#7
0
// MarshalXML marshals times into their proper format. Otherwise nothing is
// marshaled. All times are sent in UTC.
func (t NullTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if t.Time != nil {
		e.EncodeElement(t.String(), start)
	}

	return nil
}
示例#8
0
func (f ApproximationType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {

	if f < approximationTypeEnd {
		return e.EncodeElement(approximationTypeLookup[f], start)
	}

	return fmt.Errorf("invalid approximation type: %d", f)
}
示例#9
0
func (b *boolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	val := "False"
	if *b {
		val = "True"
	}
	e.EncodeElement(val, start)
	return nil
}
示例#10
0
func (d Datum) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if d.Time != nil {
		formattedDate := d.Time.Format(xmlDateFormat)
		e.EncodeElement(formattedDate, start)
	}

	return nil
}
// MarshalXML marshals NullBools to XML. Otherwise nothing is
// marshaled.
func (u UnitAmount) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if u.USD > 0 || u.EUR > 0 {
		v := (uaAlias)(u)
		e.EncodeElement(v, start)
	}

	return nil
}
示例#12
0
func (a CacheBehaviors) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedCacheBehaviors{
		Quantity: len(a),
		Items:    []CacheBehavior(a),
	}

	return e.EncodeElement(enc, start)
}
示例#13
0
func (a CustomErrorResponses) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedCustomErrorResponses{
		Quantity: len(a),
		Items:    []CustomErrorResponse(a),
	}

	return e.EncodeElement(enc, start)
}
示例#14
0
func (a Aliases) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedAliases{
		Quantity: len(a),
		Items:    []string(a),
	}

	return e.EncodeElement(enc, start)
}
示例#15
0
func (o Origins) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedOrigins{
		Quantity: len(o),
		Items:    []Origin(o),
	}

	return e.EncodeElement(enc, start)
}
示例#16
0
func (n TrustedSigners) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedTrustedSigners{
		Enabled:  n.Enabled,
		Quantity: len(n.AWSAccountNumbers),
		Items:    n.AWSAccountNumbers,
	}

	return e.EncodeElement(enc, start)
}
示例#17
0
文件: alfred.go 项目: v-yarotsky/dawg
func (a AlfredOutput) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Local: "items"}
	e.EncodeToken(start)
	for _, item := range a {
		e.EncodeElement(item, xml.StartElement{Name: xml.Name{Local: "item"}})
	}
	e.EncodeToken(start.End())
	return nil
}
示例#18
0
// writeData base64-encodes val.
func writeData(e *xml.Encoder, val []byte) error {
	var encoded bytes.Buffer
	encoder := base64.NewEncoder(base64.StdEncoding, &encoded)
	// Just writing to a buffer, can't fail.
	encoder.Write(val)
	encoder.Close()

	return e.EncodeElement(encoded.String(), dataStartElement)
}
示例#19
0
func (a GeoRestriction) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedGeoRestriction{
		RestrictionType: a.RestrictionType,
		Quantity:        len(a.Locations),
		Locations:       []string(a.Locations),
	}

	return e.EncodeElement(enc, start)
}
示例#20
0
文件: errs.go 项目: tsuna/goarista
// MarshalXML marshals the netconfInfo map as an array of XML
// <error-info> sub-elements
func (info netconfInfo) MarshalXML(e *xml.Encoder, se xml.StartElement) error {
	for key, value := range info {
		name := string(key)
		elem := xml.StartElement{Name: xml.Name{Local: name}}
		if err := e.EncodeElement(value, elem); err != nil {
			return err
		}
	}
	return nil
}
示例#21
0
func (n AllowedMethods) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	enc := EncodedAllowedMethods{
		AllowedQuantity: len(n.Allowed),
		Allowed:         n.Allowed,
		CachedQuantity:  len(n.Cached),
		Cached:          n.Cached,
	}

	return e.EncodeElement(enc, start)
}
示例#22
0
文件: plist.go 项目: v-yarotsky/dawg
func (d PDict) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Local: "dict"}
	e.EncodeToken(start)
	for k, v := range d {
		e.EncodeElement(k, xml.StartElement{Name: xml.Name{Local: "key"}})
		v.MarshalXML(e, start)
	}
	e.EncodeToken(start.End())
	return nil
}
示例#23
0
func (c *VersioningConfiguration) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var tmp InternalVersioningConfiguration
	tmp.Type = c.Type
	for k, v := range c.Params {
		tmp.Params = append(tmp.Params, InternalParam{k, v})
	}

	return e.EncodeElement(tmp, start)

}
示例#24
0
文件: plist.go 项目: v-yarotsky/dawg
func (b PBool) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var val string
	if b {
		val = "true"
	} else {
		val = "false"
	}
	e.EncodeElement("", xml.StartElement{Name: xml.Name{Local: val}})
	return nil
}
示例#25
0
func criterionMarshalXML(c Criterion, e *xml.Encoder) error {
	criterionType := ""
	switch t := c.(type) {
	case AdScheduleCriterion:
		criterionType = "AdSchedule"
	case AgeRangeCriterion:
		criterionType = "AgeRange"
	case CarrierCriterion:
		criterionType = "Carrier"
	case ContentLabelCriterion:
		criterionType = "ContentLabel"
	case GenderCriterion:
		criterionType = "Gender"
	case KeywordCriterion:
		criterionType = "Keyword"
	case LanguageCriterion:
		criterionType = "Language"
	case Location:
		criterionType = "Location"
	case MobileAppCategoryCriterion:
		criterionType = "MobileAppCategory"
	case MobileApplicationCriterion:
		criterionType = "MobileApplication"
	case MobileDeviceCriterion:
		criterionType = "MobileDevice"
	case OperatingSystemVersionCriterion:
		criterionType = "OperatingSystemVersion"
	case PlacementCriterion:
		criterionType = "Placement"
	case PlatformCriterion:
		criterionType = "Platform"
	case ProductCriterion:
		criterionType = "Product"
	case ProximityCriterion:
		criterionType = "Proximity"
	case UserInterestCriterion:
		criterionType = "CriterionUserInterest"
	case UserListCriterion:
		criterionType = "CriterionUserList"
	case VerticalCriterion:
		criterionType = "Vertical"
	case WebpageCriterion:
		criterionType = "Webpage"
	default:
		return fmt.Errorf("unknown criterion type %#v\n", t)
	}
	e.EncodeElement(&c, xml.StartElement{
		xml.Name{baseUrl, "criterion"},
		[]xml.Attr{
			xml.Attr{xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"}, criterionType},
		},
	})
	return nil
}
示例#26
0
文件: kml.go 项目: twpayne/go-kml
// MarshalXML marshals ce to e. start is ignored.
func (ce *CompoundElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if err := e.EncodeToken(ce.StartElement); err != nil {
		return err
	}
	for _, c := range ce.children {
		if err := e.EncodeElement(c, ce.StartElement); err != nil {
			return err
		}
	}
	return e.EncodeToken(ce.End())
}
示例#27
0
// MarshalXML prepends the "D:" namespace prefix on properties in the DAV: namespace
// before encoding. See multistatusWriter.
func (ps propstat) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	for k, prop := range ps.Prop {
		if prop.XMLName.Space == "DAV:" {
			prop.XMLName = xml.Name{Space: "", Local: "D:" + prop.XMLName.Local}
			ps.Prop[k] = prop
		}
	}
	// Distinct type to avoid infinite recursion of MarshalXML.
	type newpropstat propstat
	return e.EncodeElement(newpropstat(ps), start)
}
示例#28
0
文件: pose.go 项目: atuleu/go-sdf
func (p *Pose) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	if err := p.Validate(); err != nil {
		return err
	}
	start.Name.Local = "pose"
	pp := &golangPose{
		Frame:  p.Frame,
		Values: fmt.Sprintf("%f %f %f %f %f %f", p.Values[0], p.Values[1], p.Values[2], p.Values[3], p.Values[4], p.Values[5]),
	}

	return e.EncodeElement(pp, start)
}
示例#29
0
//Magic that sets downloadFormat automaticaly
func (c *ReportDefinition) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	c.DownloadFormat = DOWNLOAD_FORMAT_XML

	type Alias ReportDefinition

	start.Name = xml.Name{
		"", "reportDefinition",
	}

	e.EncodeElement((*Alias)(c), start)
	return nil
}
示例#30
0
// MarshalXML implements the xml.Marshaler interface. It encodes
// metadata name/value pairs as they would appear in an Azure
// ListBlobs response.
func (bm BlobMetadata) MarshalXML(enc *xml.Encoder, start xml.StartElement) error {
	entries := make([]blobMetadataEntry, 0, len(bm))
	for k, v := range bm {
		entries = append(entries, blobMetadataEntry{
			XMLName: xml.Name{Local: http.CanonicalHeaderKey(k)},
			Value:   v,
		})
	}
	return enc.EncodeElement(blobMetadataEntries{
		Entries: entries,
	}, start)
}