atom/xhtmlDiv.go

32 lines
693 B
Go
Raw Permalink Normal View History

2024-10-17 18:12:23 +02:00
package atom
import (
"encoding/xml"
2024-10-18 19:04:08 +02:00
"fmt"
2024-10-17 18:12:23 +02:00
)
type XHTMLDiv struct {
XMLName xml.Name `xml:"div"`
XMLNS string `xml:"xmlns,attr"`
Content string `xml:",innerxml"`
}
2025-01-24 23:06:32 +01:00
// NewXHTMLDiv creates a new XHTMLDiv. It takes in a string content and returns
// a *XHTMLDiv.
func NewXHTMLDiv(content string) *XHTMLDiv {
2024-10-17 18:12:23 +02:00
return &XHTMLDiv{
XMLNS: "http://www.w3.org/1999/xhtml",
Content: content,
}
2024-10-17 18:12:23 +02:00
}
// Check checks the XHTMLDiv for incompatibilities with RFC4287. It returns an
// error.
func (x *XHTMLDiv) Check() error {
if x.XMLNS != "http://www.w3.org/1999/xhtml" {
2024-10-18 19:04:08 +02:00
return fmt.Errorf("xmlns attribute of xhtml text %v must be http://www.w3.org/1999/xhtml", x)
2024-10-17 18:12:23 +02:00
}
return nil
}