-
Notifications
You must be signed in to change notification settings - Fork 0
/
namespace.go
144 lines (117 loc) · 4.11 KB
/
namespace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package genericode
import (
"encoding/xml"
)
type Genericode struct {
}
type CodeList struct {
Genericode
XMLName xml.Name `xml:"http://docs.oasis-open.org/codelist/ns/genericode/1.0/ CodeList"`
Annotation *Annotation `xml:"Annotation"`
Identification *Identification `xml:"Identification"`
Columns []*Column `xml:"ColumnSet>Column"`
Keys []*Key `xml:"ColumnSet>Key"`
Rows []*Row `xml:"SimpleCodeList>Row"`
columnIndex map[string]*Column
keyIndex map[string]*Key
}
func (cl *CodeList) Column(id string) *Column {
if cl.columnIndex != nil {
return cl.columnIndex[id]
}
// Fallback if index is not provided
for _, column := range cl.Columns {
if *column.Id == id {
return column
}
}
return nil
}
type Identification struct {
ShortName *TranslatableName `xml:"ShortName"`
LongName []*TranslatableName `xml:"LongName"`
Version *string `xml:"Version"`
CanonicalUri *string `xml:"CanonicalUri"`
CanonicalVersionUri *string `xml:"CanonicalVersionUri"`
LocationUri *string `xml:"LocationUri"`
AlternateFormatLocationUri *MimeTypedUri `xml:"AlternateFormatLocationUri"`
Agency *Agency `xml:"Agency"`
}
type Agency struct {
ShortName *TranslatableName `xml:"ShortName"`
LongName []*TranslatableName `xml:"LongName"`
Identifier []*string `xml:"Identifier"`
}
type Column struct {
Annotation *Annotation `xml:"Annotation"`
Id *string `xml:"Id,attr"` // Required
Use *string `xml:"Use,attr"` // Required
ShortName *TranslatableName `xml:"ShortName"`
LongName []*TranslatableName `xml:"LongName"`
CanonicalUri *string `xml:"CanonicalUri"`
CanonicalVersionUri *string `xml:"CanonicalVersionUri"`
Data *Data `xml:"Data"` // Required
codeList *CodeList
}
type Key struct {
Annotation *Annotation `xml:"Annotation"`
Id *string `xml:"Id,attr"` // Required
ShortName *TranslatableName `xml:"ShortName"`
LongName []*TranslatableName `xml:"LongName"`
CanonicalUri *string `xml:"CanonicalUri"`
CanonicalVersionUri *string `xml:"CanonicalVersionUri"`
ColumnRef []*ColumnRef `xml:"ColumnRef"` // Required
codeList *CodeList
}
type Row struct {
Annotation *Annotation `xml:"Annotation"`
Values []*Value `xml:"Value"`
}
func (row *Row) Get(column string) *string {
for _, value := range row.Values {
if *value.ColumnRef == column {
return value.SimpleValue
}
}
return nil
}
type Value struct {
Annotation *Annotation `xml:"Annotation"`
ColumnRef *string `xml:"ColumnRef,attr"`
SimpleValue *string `xml:"SimpleValue"`
ComplexValue *AnyContent `xml:"ComplexValue"`
}
type TranslatableName struct {
Value string `xml:",chardata"`
Language *string `xml:"http://www.w3.org/XML/1998/namespace lang,attr"`
}
type Data struct {
Type *string `xml:"Type,attr"`
DatatypeLibrary *string `xml:"DatatypeLibrary,attr"`
Language *string `xml:"Lang,attr"`
Parameter []*DatatypeFacet `xml:"Parameter"`
}
type DatatypeFacet struct {
Facet string `xml:",chardata"` // Required
ShortName *string `xml:"ShortName,attr"` // Required
LongName *string `xml:"LongName,attr"`
}
type ColumnRef struct {
Annotation *Annotation `xml:"Annotation"`
Ref *string `xml:"Ref,attr"`
}
type MimeTypedUri struct {
URI string `xml:",chardata"` // Required
MimeType *string `xml:"MimeType,attr"`
}
type Annotation struct {
Description []*AnyLanguageContent `xml:"Description"`
AppInfo *AnyContent `xml:"AppInfo"`
}
type AnyContent struct {
Content string `xml:",innerxml"`
}
type AnyLanguageContent struct {
Content string `xml:",innerxml"`
Language *string `xml:"http://www.w3.org/XML/1998/namespace lang,attr"`
}