-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbl-update-titleStmt-and-seriesStmt.xq
More file actions
125 lines (103 loc) · 3.04 KB
/
Copy pathbl-update-titleStmt-and-seriesStmt.xq
File metadata and controls
125 lines (103 loc) · 3.04 KB
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
xquery version "3.1";
import module namespace functx="http://www.functx.com";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare default element namespace "http://www.tei-c.org/ns/1.0";
declare variable $path-to-repo := "/home/arren/Documents/GitHub/britishLibrary-data";
declare variable $in-coll := collection($path-to-repo||"/data/tei/");
declare variable $series-title := "Syriac Manuscripts in the British Library";
declare variable $series-idno := "https://bl.syriac.uk";
declare variable $editor-uri-base := "https://bl.syriac.uk/documentation/editors.xml";
declare variable $general-editors :=
[
map {
"role": "general",
"id": "dmichelson",
"name": "D. Michelson"
},
map {
"role": "general",
"id": "wpotter",
"name": "W. Potter"
}
];
declare variable $technical-editors :=
[
map {
"role": "technical",
"id": "dmichelson",
"name": "D. Michelson"
},
map {
"role": "technical",
"id": "wpotter",
"name": "W. Potter"
},
map {
"role": "technical",
"id": "dschwartz",
"name": "Daniel L. Schwartz"
}
];
declare variable $series-stmt :=
element {"seriesStmt"} {
element {"title"} {
attribute {"level"} {"s"},
attribute {"xml:lang"} {"en"},
$series-title
},
for $ed in $general-editors?* return local:create-editor-element($ed),
for $ed in $technical-editors?* return local:create-editor-element($ed),
element {"idno"} {
attribute {"type"} {"URI"},
$series-idno
}
};
declare variable $author-wright :=
element {"author"} {
attribute {"ref"} {$editor-uri-base||"#"||"wwright"},
"William Wright"
(:<author ref="https://bl.syriac.uk/documentation/editors.xml#wwright">William Wright</author>:)
};
declare function local:create-editor-element($editorInfo as item()*)
as node()
{
element {"editor"} {
attribute {"role"} {$editorInfo?role},
attribute {"ref"} {$editor-uri-base||"#"||$editorInfo?id},
$editorInfo?name
}
};
for $doc in $in-coll
let $titleStmt := $doc//titleStmt
(: normalize the title string, and supply level and xml:lang attributes :)
let $titleString := $titleStmt/title[@level="a" or not(@level)]/text() => normalize-space()
let $title :=
element {"title"} {
attribute {"level"} {"a"},
attribute {"xml:lang"} {"en"},
$titleString
}
(: gather elements that won't change :)
let $sponsor := $titleStmt/sponsor
let $funder := $titleStmt/funder
let $principal := $titleStmt/principal
(: get the creator editors, ignoring the one for Wright (he'll be an author instead) :)
let $creatorEditors := $titleStmt/editor[@role="creator"][not(@ref = "https://bl.syriac.uk/documentation/editors.xml#wwright")]
let $reviewEditors := $titleStmt/editor[@role="review-editor"]
let $respStmts := $titleStmt/respStmt
let $newTitleStmt :=
element {"titleStmt"}
{
$title,
$sponsor,
$funder,
$principal,
$author-wright,
$creatorEditors,
$reviewEditors,
$respStmts
}
return (
replace node $doc//titleStmt with $newTitleStmt,
insert node $series-stmt after $doc//fileDesc/publicationStmt
)