Compare commits

..

No commits in common. "b76e529ca3ce3005d94244380961e649fb10f682" and "566227773ed5a67ff904df5af45b873014de6f6a" have entirely different histories.

4 changed files with 6 additions and 30 deletions

View File

@ -8,7 +8,7 @@ import (
type Category struct {
*CommonAttributes
Content Content `xml:"content"` // undefinedContent in RFC4287
Content Content `xml:"content"` // should this even exist in here?
Term string `xml:"term,attr"`
Scheme URI `xml:"scheme,attr,omitempty"`
Label string `xml:"label,attr,omitempty"`

13
icon.go
View File

@ -1,26 +1,15 @@
package atomfeed
import (
"errors"
"fmt"
)
import "errors"
type Icon struct {
*CommonAttributes
URI URI `xml:"uri"`
}
func NewIcon(uri string) *Icon {
return &Icon{URI: URI(uri)}
}
func (i *Icon) Check() error {
if i.URI == "" {
return errors.New("uri element of icon empty")
} else {
if !isValidURI(i.URI) {
return fmt.Errorf("uri attribute %v of icon not correctly formatted", i.URI)
}
}
return nil

4
id.go
View File

@ -19,10 +19,6 @@ func NewID() *ID {
func (i *ID) Check() error {
if i.URI == "" {
return errors.New("uri element of id empty")
} else {
if !isValidURI(i.URI) {
return fmt.Errorf("uri element %v of id not correctly formatted", i.URI)
}
}
return nil

17
link.go
View File

@ -7,8 +7,8 @@ import (
type Link struct {
*CommonAttributes
Title Text `xml:"title,attr,omitempty"`
Content Content `xml:"content"` // undefinedContent in RFC4287
Title *Text `xml:"title,attr,omitempty"`
Content *Content `xml:"content"`
Href URI `xml:"href,attr"`
Rel string `xml:"rel,attr,omitempty"`
Type MediaType `xml:"type,attr,omitempty"`
@ -16,22 +16,13 @@ type Link struct {
Length uint `xml:"length,attr,omitempty"`
}
func NewLink(href string) (*Link, error) {
content, err := NewContent(InlineText, "", "")
if err != nil {
return nil, fmt.Errorf("error creating content element: %v", err)
}
return &Link{Href: URI(href), Content: content}, nil
}
func (l *Link) Check() error {
if l.Href == "" {
return errors.New("href attribute of link empty")
}
if l.Title != nil {
if err := l.Title.Check(); err != nil {
if err := (*l.Title).Check(); err != nil {
return fmt.Errorf("title attribute of link %v: %v", l.Href, err)
}
}
@ -39,7 +30,7 @@ func (l *Link) Check() error {
if l.Content == nil {
return fmt.Errorf("no content element of link %v", l.Href)
} else {
if err := l.Content.Check(); err != nil {
if err := (*l.Content).Check(); err != nil {
return fmt.Errorf("content element of link %v: %v", l.Href, err)
}
}