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

View File

@@ -8,21 +8,14 @@ import (
type Category struct {
*CommonAttributes
Content string `xml:",chardata"` // undefinedContent in RFC4287
Term string `xml:"term,attr"`
Scheme IRI `xml:"scheme,attr,omitempty"`
Label string `xml:"label,attr,omitempty"`
Term string `xml:"term,attr"`
Scheme IRI `xml:"scheme,attr,omitempty"`
Label string `xml:"label,attr,omitempty"`
}
// NewCategory creates a new Category. It returns a *Category and an error.
func NewCategory(term, content string) (*Category, error) {
if content != "" {
if !isValidXML(content) {
return nil, fmt.Errorf("%v not valid XML", content)
}
}
return &Category{Term: term, Content: content}, nil
func NewCategory(term string) *Category {
return &Category{Term: term}
}
// SetLabel sets the label of the Category.
@@ -47,11 +40,5 @@ func (c *Category) Check() error {
return fmt.Errorf("label attribute %v of category not correctly escaped", c.Label)
}
if c.Content != "" {
if !isValidXML(c.Content) {
return fmt.Errorf("content element %v of category not valid XML", c.Content)
}
}
return nil
}