-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinsert-bhse-editions-translations-ptrs.xql
30 lines (25 loc) · 1.25 KB
/
insert-bhse-editions-translations-ptrs.xql
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
xquery version "3.0";
(:Convert TEI exported from Zotero to Syriaca TEI bibl records:)
declare default element namespace "http://www.tei-c.org/ns/1.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace syriaca = "http://syriaca.org";
declare namespace functx = "http://www.functx.com";
declare function syriaca:update-attribute($input-node as node()*,$attribute as xs:string,$attribute-value as xs:string)
as node()*
{
for $node in $input-node
return
element {xs:QName(name($node))} {
$node/@*[name()!=$attribute],
attribute {xs:QName($attribute)} {$attribute-value},
$node/node()}
};
let $works := collection("/db/apps/srophe-data/data/works/tei/")/TEI/text/body/bibl
let $bibls := collection("/db/apps/srophe-data/data/bibl/tei/")/TEI/text/body/biblStruct
for $bibl in $works//bibl[idno/@type='zotero']
let $idno-zotero := $bibl/idno[@type='zotero']
let $bibl-matching := $bibls/(analytic|monogr)[idno[@type='zotero']=$idno-zotero]
let $ptr := element ptr {attribute target {$bibl-matching/idno[@type='URI' and matches(.,'http://syriaca.org/bibl')]}}
return
(update insert $ptr following $idno-zotero,
update delete $idno-zotero)