diff --git a/category.go b/category.go index a631f87..fe8ea73 100644 --- a/category.go +++ b/category.go @@ -1,12 +1,14 @@ package atom import ( + "encoding/xml" "errors" "fmt" "html" ) type Category struct { + XMLName xml.Name `xml:"category"` *CommonAttributes Term string `xml:"term,attr"` Scheme IRI `xml:"scheme,attr,omitempty"` diff --git a/entry.go b/entry.go index dbe2d87..4eb7dd6 100644 --- a/entry.go +++ b/entry.go @@ -1,6 +1,7 @@ package atom import ( + "encoding/xml" "errors" "fmt" "strings" @@ -12,16 +13,17 @@ import ( // a non-empty atom:summary element when the entry contains no atom:content // element. type Entry struct { + XMLName xml.Name `xml:"entry"` *CommonAttributes - Authors []*Person `xml:"author,omitempty"` - Categories []*Category `xml:"category,omitempty"` - Content Content `xml:"content,omitempty"` - Contributors []*Person `xml:"contributors,omitempty"` - ID *ID `xml:"id"` - Links []*Link `xml:"link,omitempty"` + Authors []*Person `xml:"author,omitempty"` + Categories []*Category `xml:",omitempty"` + Content Content `xml:",omitempty"` + Contributors []*Person `xml:"contributors,omitempty"` + ID *ID + Links []*Link `xml:",omitempty"` Published *Date `xml:"published,omitempty"` Rights Text `xml:"rights,omitempty"` - Source *Source `xml:"source,omitempty"` + Source *Source `xml:",omitempty"` Summary Text `xml:"summary,omitempty"` Title Text `xml:"title"` Updated *Date `xml:"updated"` diff --git a/extensionAttribute.go b/extensionAttribute.go index 5967bb0..d6fccb4 100644 --- a/extensionAttribute.go +++ b/extensionAttribute.go @@ -5,6 +5,7 @@ import ( "errors" ) +// TODO: Is this really correct? type ExtensionAttribute struct { Value any `xml:",attr"` XMLName xml.Name diff --git a/extensionElement.go b/extensionElement.go index 1f6c1d0..77574b3 100644 --- a/extensionElement.go +++ b/extensionElement.go @@ -5,6 +5,7 @@ import ( "errors" ) +// TODO: Is this really correct? type ExtensionElement struct { Value any `xml:",innerxml"` XMLName xml.Name diff --git a/feed.go b/feed.go index 7b13b09..73a9257 100644 --- a/feed.go +++ b/feed.go @@ -10,20 +10,20 @@ import ( type Feed struct { XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"` *CommonAttributes - Authors []*Person `xml:"author,omitempty"` - Categories []*Category `xml:"category,omitempty"` - Contributors []*Person `xml:"contributor,omitempty"` - Generator *Generator `xml:"generator,omitempty"` - Icon *Icon `xml:"icon,omitempty"` - ID *ID `xml:"id"` - Links []*Link `xml:"link,omitempty"` - Logo *Logo `xml:"logo,omitempty"` + Authors []*Person `xml:"author,omitempty"` + Categories []*Category `xml:",omitempty"` + Contributors []*Person `xml:"contributor,omitempty"` + Generator *Generator `xml:",omitempty"` + Icon *Icon `xml:",omitempty"` + ID *ID + Links []*Link `xml:",omitempty"` + Logo *Logo `xml:",omitempty"` Rights Text `xml:"rights,omitempty"` Subtitle Text `xml:"subtitle,omitempty"` Title Text `xml:"title"` Updated *Date `xml:"updated"` Extensions []*ExtensionElement `xml:",any,omitempty"` - Entries []*Entry `xml:"entry,omitempty"` + Entries []*Entry `xml:",omitempty"` } // NewFeed creates a new Feed. It returns a *Feed and an error. diff --git a/generator.go b/generator.go index f51d9aa..ca89b83 100644 --- a/generator.go +++ b/generator.go @@ -1,12 +1,14 @@ package atom import ( + "encoding/xml" "errors" "fmt" "html" ) type Generator struct { + XMLName xml.Name `xml:"generator"` *CommonAttributes URI IRI `xml:"uri,attr,omitempty"` Version string `xml:"version,attr,omitempty"` diff --git a/icon.go b/icon.go index 789c1b2..783aae9 100644 --- a/icon.go +++ b/icon.go @@ -1,11 +1,13 @@ package atom import ( + "encoding/xml" "errors" "fmt" ) type Icon struct { + XMLName xml.Name `xml:"icon"` *CommonAttributes URI IRI `xml:",chardata"` } diff --git a/id.go b/id.go index 608cf43..77f6600 100644 --- a/id.go +++ b/id.go @@ -1,11 +1,13 @@ package atom import ( + "encoding/xml" "errors" "fmt" ) type ID struct { + XMLName xml.Name `xml:"id"` *CommonAttributes URI IRI `xml:",chardata"` } diff --git a/inlineOtherContent.go b/inlineOtherContent.go index 4c5eb75..dd8fc08 100644 --- a/inlineOtherContent.go +++ b/inlineOtherContent.go @@ -1,12 +1,14 @@ package atom import ( + "encoding/xml" "errors" "fmt" "mime" ) type InlineOtherContent struct { + XMLName xml.Name `xml:"content"` *CommonAttributes AnyElement any `xml:",chardata"` Type MediaType `xml:"type,attr,omitempty"` diff --git a/inlineTextContent.go b/inlineTextContent.go index a4557b6..51c130d 100644 --- a/inlineTextContent.go +++ b/inlineTextContent.go @@ -1,11 +1,13 @@ package atom import ( + "encoding/xml" "errors" "fmt" ) type InlineTextContent struct { + XMLName xml.Name `xml:"content"` *CommonAttributes Type string `xml:"type,attr,omitempty"` // Must be text or html Text string `xml:",chardata"` diff --git a/inlineXHTMLContent.go b/inlineXHTMLContent.go index 0aae65e..0a7cc11 100644 --- a/inlineXHTMLContent.go +++ b/inlineXHTMLContent.go @@ -1,11 +1,13 @@ package atom import ( + "encoding/xml" "errors" "fmt" ) type InlineXHTMLContent struct { + XMLName xml.Name `xml:"content"` *CommonAttributes XHTMLDiv *XHTMLDiv Type string `xml:"type,attr"` diff --git a/link.go b/link.go index fcfef06..6671f8d 100644 --- a/link.go +++ b/link.go @@ -1,12 +1,14 @@ package atom import ( + "encoding/xml" "errors" "fmt" "strings" ) type Link struct { + XMLName xml.Name `xml:"link"` *CommonAttributes Title string `xml:"title,attr,omitempty"` Href IRI `xml:"href,attr"` diff --git a/logo.go b/logo.go index 419fbac..377aa45 100644 --- a/logo.go +++ b/logo.go @@ -1,11 +1,13 @@ package atom import ( + "encoding/xml" "errors" "fmt" ) type Logo struct { + XMLName xml.Name `xml:"logo"` *CommonAttributes URI IRI `xml:",chardata"` } diff --git a/outOfLineContent.go b/outOfLineContent.go index 3c44a75..91be8c2 100644 --- a/outOfLineContent.go +++ b/outOfLineContent.go @@ -1,12 +1,14 @@ package atom import ( + "encoding/xml" "errors" "fmt" "mime" ) type OutOfLineContent struct { + XMLName xml.Name `xml:"content"` *CommonAttributes Type MediaType `xml:"type,attr,omitempty"` SRC IRI `xml:"src,attr"` diff --git a/source.go b/source.go index d733ac6..88580b8 100644 --- a/source.go +++ b/source.go @@ -1,17 +1,21 @@ package atom -import "fmt" +import ( + "encoding/xml" + "fmt" +) type Source struct { + XMLName xml.Name `xml:"source"` *CommonAttributes Authors []*Person `xml:"author,omitempty"` - Categories []*Category `xml:"category,omitempty"` + Categories []*Category `xml:",omitempty"` Contributors []*Person `xml:"contributor,omitempty"` - Generator *Generator `xml:"generator,omitempty"` - Icon *Icon `xml:"icon,omitempty"` - ID *ID `xml:"id,omitempty"` - Links []*Link `xml:"link,omitempty"` - Logo *Logo `xml:"logo,omitempty"` + Generator *Generator `xml:",omitempty"` + Icon *Icon `xml:",omitempty"` + ID *ID `xml:",omitempty"` + Links []*Link `xml:",omitempty"` + Logo *Logo `xml:",omitempty"` Rights Text `xml:"rights,omitempty"` Subtitle Text `xml:"subtitle,omitempty"` Title Text `xml:"title,omitempty"`