No more undefined content in link and category

It seems that undefined content is only mentioned in RFC4287 because
link and category are elements and those usually need some content.
This commit is contained in:
2024-10-17 18:57:43 +02:00
parent e73b78ef30
commit d11b229691
2 changed files with 7 additions and 33 deletions

17
link.go
View File

@@ -9,7 +9,6 @@ import (
type Link struct {
*CommonAttributes
Title string `xml:"title,attr,omitempty"`
Content string `xml:",chardata"` // undefinedContent in RFC4287
Href IRI `xml:"href,attr"`
Rel string `xml:"rel,attr,omitempty"`
Type MediaType `xml:"type,attr,omitempty"`
@@ -18,14 +17,8 @@ type Link struct {
}
// NewLink creates a new Link. It returns a *Link and an error.
func NewLink(href, content string) (*Link, error) {
if content != "" {
if !isValidXML(content) {
return nil, fmt.Errorf("%v not valid XML", content)
}
}
return &Link{Href: IRI(href), Content: content}, nil
func NewLink(href, content string) *Link {
return &Link{Href: IRI(href)}
}
// Check checks the Link for incompatibilities with RFC4287. It returns an
@@ -57,12 +50,6 @@ func (l *Link) Check() error {
}
}
if l.Content != "" {
if !isValidXML(l.Content) {
return fmt.Errorf("content element %v of link not valid XML", l.Content)
}
}
return nil
}