Compare commits

..

No commits in common. "3172a4865a2d7939ca6d17c5e6bad4dfc454dc2f" and "9c38048bd265f02d97b5cc045e025e4fea75ffa6" have entirely different histories.

4 changed files with 8 additions and 26 deletions

View File

@ -1,3 +1,4 @@
# atom
# atom-feed
An extensible implementation of an Atom feed that aims to be very close to RFC4287.

View File

@ -8,22 +8,6 @@ type CommonAttributes struct {
UndefinedAttributes []*ExtensionAttribute `xml:",any"`
}
// NewCommonAttributes creates a new set of CommonAttributes. It returns a
// *CommonAttributes.
func NewCommonAttributes() *CommonAttributes {
return new(CommonAttributes)
}
// AddExtensionAttribute adds the ExtensionAttribute to the CommonAttributes.
func (c *CommonAttributes) AddExtensionAttribute(e *ExtensionAttribute) {
if c.UndefinedAttributes == nil {
c.UndefinedAttributes = make([]*ExtensionAttribute, 1)
c.UndefinedAttributes[0] = e
} else {
c.UndefinedAttributes = append(c.UndefinedAttributes, e)
}
}
// Check checks the CommonAttributes for incompatibilities with RFC4287. It
// returns an error.
func (c *CommonAttributes) Check() error {

View File

@ -1,24 +1,20 @@
package atom
import (
"encoding/xml"
"errors"
"fmt"
)
// TODO: Is this really correct?
type ExtensionAttribute struct {
Attr string `xml:",attr"`
}
// NewExtensionAttribute creates a new ExtensionAttribute. It returns a
// *ExtensionAttribute.
func NewExtensionAttribute(name, value string) *ExtensionAttribute {
return &ExtensionAttribute{Attr: fmt.Sprint(name, `="`, value, `"`)}
Value any `xml:",attr"`
XMLName xml.Name
}
// Check checks the ExtensionAttribute for incompatibilities with RFC4287. It
// returns an error.
func (e *ExtensionAttribute) Check() error {
if e.Attr == "" {
if e.Value == nil {
return errors.New("value element of extension attribute empty")
}

View File

@ -5,6 +5,7 @@ import (
"errors"
)
// TODO: Is this really correct?
type ExtensionElement struct {
Value any `xml:",innerxml"`
XMLName xml.Name