mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 00:55:32 +00:00
Better structure of files; introduced XML models
This commit is contained in:
71
xmlmodels/common.go
Normal file
71
xmlmodels/common.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package xmlmodels
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/xsdtime"
|
||||
)
|
||||
|
||||
var InvalidDateError = errors.New("Invalid date")
|
||||
|
||||
const DateLayout = "2006-01-02"
|
||||
|
||||
type KGPZDate struct {
|
||||
XMLName xml.Name `xml:"datum"`
|
||||
DateAttributes
|
||||
Value
|
||||
}
|
||||
|
||||
type DateAttributes struct {
|
||||
When xsdtime.XSDDate `xml:"when,attr"`
|
||||
NotBefore xsdtime.XSDDate `xml:"notBefore,attr"`
|
||||
NotAfter xsdtime.XSDDate `xml:"notAfter,attr"`
|
||||
From xsdtime.XSDDate `xml:"from,attr"`
|
||||
To xsdtime.XSDDate `xml:"to,attr"`
|
||||
Cert string `xml:"cert,attr"`
|
||||
}
|
||||
|
||||
type URL struct {
|
||||
XMLName xml.Name `xml:"url"`
|
||||
Address string `xml:"address,attr"`
|
||||
Value
|
||||
}
|
||||
|
||||
type AnnotationNote struct {
|
||||
Annotations []Annotation `xml:"anmerkung"`
|
||||
Notes []Note `xml:"vermerk"`
|
||||
}
|
||||
|
||||
type Annotation struct {
|
||||
XMLName xml.Name `xml:"anmerkung"`
|
||||
Value
|
||||
Inner
|
||||
}
|
||||
|
||||
type Note struct {
|
||||
XMLName xml.Name `xml:"vermerk"`
|
||||
Value
|
||||
Inner
|
||||
}
|
||||
|
||||
type Identifier struct {
|
||||
ID string `xml:"id,attr"`
|
||||
keys []string
|
||||
}
|
||||
|
||||
func (i Identifier) Keys() []string {
|
||||
if len(i.keys) > 0 {
|
||||
return i.keys
|
||||
}
|
||||
i.keys = []string{i.ID}
|
||||
return i.keys
|
||||
}
|
||||
|
||||
type Value struct {
|
||||
Chardata string `xml:",chardata"`
|
||||
}
|
||||
|
||||
type Inner struct {
|
||||
InnerXML string `xml:",innerxml"`
|
||||
}
|
||||
Reference in New Issue
Block a user