38 lines
908 B
Go
38 lines
908 B
Go
package atom
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type XHTMLText struct {
|
|
*CommonAttributes
|
|
XHTMLDiv *XHTMLDiv
|
|
Type string `xml:"type,attr"` // Must be xhtml
|
|
}
|
|
|
|
// isText checks whether the XHTMLText is a Text. It returns a bool.
|
|
func (x *XHTMLText) isText() bool { return true }
|
|
|
|
// newPlainText creates a new PlainText. It returns a *PlainText.
|
|
func newXHTMLText(textType, content string) *XHTMLText {
|
|
return &XHTMLText{
|
|
CommonAttributes: NewCommonAttributes(),
|
|
Type: textType,
|
|
XHTMLDiv: NewXHTMLDiv(content),
|
|
}
|
|
}
|
|
|
|
// Check checks the XHTMLText for incompatibilities with RFC4287. It returns an
|
|
// error.
|
|
func (x *XHTMLText) Check() error {
|
|
if x.Type != "xhtml" {
|
|
return fmt.Errorf("type attribute of xhtml text %v must be xhtml", x)
|
|
}
|
|
|
|
if err := x.XHTMLDiv.Check(); err != nil {
|
|
return fmt.Errorf("xhtml div element %v of xhtml text %v: %v", x.XHTMLDiv, x, err)
|
|
}
|
|
|
|
return nil
|
|
}
|