Compare commits

...

2 Commits

2 changed files with 13 additions and 9 deletions

View File

@ -6,6 +6,10 @@ import (
"fmt" "fmt"
) )
// It is advisable that each atom:entry element contain a non-empty atom:title
// element, a non-empty atom:content element when that element is present, and
// a non-empty atom:summary element when the entry contains no atom:content
// element.
type Entry struct { type Entry struct {
*CommonAttributes *CommonAttributes
Authors []*Person `xml:"author,omitempty"` Authors []*Person `xml:"author,omitempty"`
@ -15,10 +19,10 @@ type Entry struct {
ID *ID `xml:"id"` ID *ID `xml:"id"`
Links []*Link `xml:"link,omitempty"` Links []*Link `xml:"link,omitempty"`
Published *Date `xml:"published,omitempty"` Published *Date `xml:"published,omitempty"`
Rights *Text `xml:"rights,omitempty"` Rights Text `xml:"rights,omitempty"`
Source *Source `xml:"source,omitempty"` Source *Source `xml:"source,omitempty"`
Summary *Text `xml:"summary,omitempty"` Summary Text `xml:"summary,omitempty"`
Title *Text `xml:"title"` Title Text `xml:"title"`
Updated *Date `xml:"updated"` Updated *Date `xml:"updated"`
Extensions []*ExtensionElement `xml:",any,omitempty"` Extensions []*ExtensionElement `xml:",any,omitempty"`
} }
@ -93,7 +97,7 @@ func (e *Entry) Check() error {
} }
if e.Rights != nil { if e.Rights != nil {
if err := (*e.Rights).Check(); err != nil { if err := e.Rights.Check(); err != nil {
return fmt.Errorf("rights element of entry %v: %v", e.ID.URI, err) return fmt.Errorf("rights element of entry %v: %v", e.ID.URI, err)
} }
} }
@ -105,7 +109,7 @@ func (e *Entry) Check() error {
} }
if e.Summary != nil { if e.Summary != nil {
if err := (*e.Summary).Check(); err != nil { if err := e.Summary.Check(); err != nil {
return fmt.Errorf("summary element of entry %v: %v", e.ID.URI, err) return fmt.Errorf("summary element of entry %v: %v", e.ID.URI, err)
} }
} }
@ -113,7 +117,7 @@ func (e *Entry) Check() error {
if e.Title == nil { if e.Title == nil {
return fmt.Errorf("no title element of entry %v", e.ID.URI) return fmt.Errorf("no title element of entry %v", e.ID.URI)
} else { } else {
if err := (*e.Title).Check(); err != nil { if err := e.Title.Check(); err != nil {
return fmt.Errorf("title element of entry %v: %v", e.ID.URI, err) return fmt.Errorf("title element of entry %v: %v", e.ID.URI, err)
} }
} }

View File

@ -26,9 +26,9 @@ type Feed struct {
Entries []*Entry `xml:"entry,omitempty"` Entries []*Entry `xml:"entry,omitempty"`
} }
// atom:feed elements MUST NOT contain more than one atom:link // atom:feed elements MUST NOT contain more than one atom:link element with a
// element with a rel attribute value of "alternate" that has the // rel attribute value of "alternate" that has the same combination of type and
// same combination of type and hreflang attribute values. // hreflang attribute values.
func hasAlternateDuplicateLinks(l []*Link) bool { func hasAlternateDuplicateLinks(l []*Link) bool {
linkMap := make(map[string]bool) linkMap := make(map[string]bool)