38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package atom
|
|
|
|
import "fmt"
|
|
|
|
type CommonAttributes struct {
|
|
Base IRI `xml:"base,attr,omitempty"`
|
|
Lang LanguageTag `xml:"lang,attr,omitempty"`
|
|
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 {
|
|
for i, e := range c.UndefinedAttributes {
|
|
if err := e.Check(); err != nil {
|
|
return fmt.Errorf("extension attribute %v of common attributes: %v", i, err)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|