mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 09:05:30 +00:00
44 lines
796 B
Go
44 lines
796 B
Go
package xmlmodels
|
|
|
|
import (
|
|
"encoding/json"
|
|
"encoding/xml"
|
|
"strings"
|
|
)
|
|
|
|
type Work struct {
|
|
XMLName xml.Name `xml:"werk"`
|
|
URLs []URL `xml:"url"`
|
|
Citation Citation `xml:"zitation"`
|
|
PreferredTitle string `xml:"preferred"`
|
|
AgentRefs []AgentRef `xml:"akteur"`
|
|
Identifier
|
|
AnnotationNote
|
|
}
|
|
|
|
func (w Work) Name() string {
|
|
return "work"
|
|
}
|
|
|
|
func (p Work) ReferencesAgent(a string) (*AgentRef, bool) {
|
|
for _, i := range p.AgentRefs {
|
|
if strings.HasPrefix(i.Ref, a) {
|
|
return &i, true
|
|
}
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
type Citation struct {
|
|
XMLName xml.Name `xml:"zitation"`
|
|
Title string `xml:"title"`
|
|
Year []string `xml:"year"`
|
|
Value
|
|
Inner
|
|
}
|
|
|
|
func (w Work) String() string {
|
|
data, _ := json.MarshalIndent(w, "", " ")
|
|
return string(data)
|
|
}
|