Better reverse link resoving

This commit is contained in:
Simon Martens
2025-01-01 23:49:09 +01:00
parent 7539a2dca7
commit 3f294680c0
13 changed files with 259 additions and 99 deletions

View File

@@ -1,8 +1,8 @@
package xmlmodels
import (
"encoding/json"
"encoding/xml"
"fmt"
"strings"
)
@@ -16,6 +16,10 @@ type Work struct {
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) {
@@ -34,5 +38,6 @@ type Citation struct {
}
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)
data, _ := json.MarshalIndent(w, "", " ")
return string(data)
}