mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 17:15:31 +00:00
Better structure of files; introduced XML models
This commit is contained in:
38
xmlmodels/works.go
Normal file
38
xmlmodels/works.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package xmlmodels
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"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 (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 {
|
||||
return fmt.Sprintf("URLs: %v, Citation: %v, PreferredTitle: %s, Akteur: %v, Identifier: %v, AnnotationNote: %v\n", w.URLs, w.Citation, w.PreferredTitle, w.AgentRefs, w.Identifier, w.AnnotationNote)
|
||||
}
|
||||
Reference in New Issue
Block a user