-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredit-with-resp-change-log.xq
More file actions
61 lines (47 loc) · 1.87 KB
/
Copy pathcredit-with-resp-change-log.xq
File metadata and controls
61 lines (47 loc) · 1.87 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
xquery version "3.1";
import module namespace functx="http://www.functx.com";
declare default element namespace "http://www.tei-c.org/ns/1.0";
declare variable $local:path-to-repo :=
"/home/arren/Documents/GitHub/britishLibrary-data";
declare variable $local:in-coll :=
collection($local:path-to-repo||"/data/tei/");
declare variable $local:delimiter := ",";
declare variable $local:csv-in :=
let $path-to-csv := "/home/arren/Documents/GitHub/sandbox/syriaca_BL-data_extent_ingest.csv"
let $csv-string := file:read-text($path-to-csv)
return csv:parse($csv-string, map {"header": "yes", "separator": $local:delimiter});
declare variable $local:editor-uri-base :=
"http://syriaca.org/documentation/editors.xml#";
declare variable $local:editor-id := "kurban";
declare variable $local:editor-name := "Kurt Urban";
declare variable $local:resp-statement :=
"Folio extent edited by";
declare variable $local:revisionDesc-change :=
"CHANGED: added or corrected folio extent values";
let $resp :=
element {"respStmt"} {
element {"resp"} {$local:resp-statement},
element {"name"} {
attribute {"type"} {"person"},
attribute {"ref"} {$local:editor-uri-base||$local:editor-id},
$local:editor-name
}
}
let $change :=
element {"change"} {
attribute {"who"} {$local:editor-uri-base||$local:editor-id},
attribute {"when"} {current-date()},
$local:revisionDesc-change
}
let $fileUris :=
for $rec in $local:csv-in/*:csv/*:record
return $rec/*:fileName/text()
let $fileUris := distinct-values($fileUris)
for $doc in $local:in-coll
let $docUri := substring-after(document-uri($doc), $local:path-to-repo)
where functx:is-value-in-sequence($docUri, $fileUris)
return (
insert node $resp as last into $doc//titleStmt,
replace value of node $doc//publicationStmt/date with current-date(),
insert node $change as first into $doc//revisionDesc
)