package atom import ( "encoding/xml" "fmt" ) type InlineTextContent struct { XMLName xml.Name `xml:"content"` *CommonAttributes Type string `xml:"type,attr,omitempty"` // Must be text or html Text string `xml:",chardata"` } // newInlineTextContent creates a new InlineTextContent. It returns a // *InlineTextContent. func newInlineTextContent(mediaType, text string) *InlineTextContent { return &InlineTextContent{ CommonAttributes: NewCommonAttributes(), Type: mediaType, Text: text, } } // isContent checks whether the InlineTextContent is a Content. It returns a // bool. func (i *InlineTextContent) isContent() bool { return true } // hasSRC checks whether the InlineTextContent has a SRC attribute. It returns // a bool. func (i *InlineTextContent) hasSRC() bool { return false } // getType returns the Type of the InlineTextContent as a string. func (i *InlineTextContent) getType() string { return i.Type } // Check checks the InlineTextContent for incompatibilities with RFC4287. It // returns an error. func (i *InlineTextContent) Check() error { if i.Type != "" && i.Type != "text" && i.Type != "html" { return fmt.Errorf("type attribute of inline text content %v must be text or html if not omitted", i) } return nil }