2024-10-16 21:28:04 +02:00
|
|
|
package atom
|
2024-10-13 17:19:40 +02:00
|
|
|
|
2024-10-17 21:44:19 +02:00
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
)
|
2024-10-13 17:19:40 +02:00
|
|
|
|
|
|
|
type CommonAttributes struct {
|
2024-10-17 21:44:19 +02:00
|
|
|
Base IRI `xml:"base,attr,omitempty"`
|
|
|
|
Lang LanguageTag `xml:"lang,attr,omitempty"`
|
|
|
|
UndefinedAttributes []*xml.Attr `xml:",attr,omitempty"`
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-17 20:48:32 +02:00
|
|
|
// NewCommonAttributes creates a new set of CommonAttributes. It returns a
|
|
|
|
// *CommonAttributes.
|
|
|
|
func NewCommonAttributes() *CommonAttributes {
|
|
|
|
return new(CommonAttributes)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddExtensionAttribute adds the ExtensionAttribute to the CommonAttributes.
|
2024-10-17 21:44:19 +02:00
|
|
|
func (c *CommonAttributes) AddExtensionAttribute(name, value string) {
|
2024-10-17 20:48:32 +02:00
|
|
|
if c.UndefinedAttributes == nil {
|
2024-10-17 21:44:19 +02:00
|
|
|
c.UndefinedAttributes = make([]*xml.Attr, 1)
|
|
|
|
c.UndefinedAttributes[0] = &xml.Attr{Name: xml.Name{Local: name}, Value: value}
|
2024-10-17 20:48:32 +02:00
|
|
|
} else {
|
2024-10-17 21:44:19 +02:00
|
|
|
c.UndefinedAttributes = append(c.UndefinedAttributes, &xml.Attr{Name: xml.Name{Local: name}, Value: value})
|
2024-10-17 20:48:32 +02:00
|
|
|
}
|
|
|
|
}
|