-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeople.xquery
63 lines (53 loc) · 3.18 KB
/
people.xquery
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
import module namespace bod = "http://www.bodleian.ox.ac.uk/bdlss" at "https://raw.githubusercontent.com/bodleian/consolidated-tei-schema/master/msdesc2solr.xquery";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare option saxon:output "indent=yes";
<add>
{
let $doc := doc("../../hebrew-mss/authority/persons_master.xml")
let $collection := collection("../collections?select=*.xml;recurse=yes")
let $people := $doc//tei:person
for $person in $people
let $id := $person/@xml:id/string()
let $name := normalize-space($person//tei:persName[@type = 'display' or (@type = 'variant' and not(preceding-sibling::tei:persName))][1]/string())
let $isauthor := boolean($collection//tei:author[@key = $id or .//persName/@key = $id])
(: This doesn't work in Genizah because most are also authors but not catalogued as such: let $issubject := boolean($collection//tei:msItem/tei:title//tei:persName[not(@role) and @key = $id]) :)
let $mss1 := $collection//tei:TEI[.//(tei:persName)[@key = $id]]/concat('/catalog/', string(@xml:id), '|', (./tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/tei:idno)[1]/text())
let $mss2 := $collection//tei:TEI[.//(tei:author)[@key = $id]]/concat('/catalog/', string(@xml:id), '|', (./tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/tei:idno)[1]/text())
let $mss := distinct-values(($mss1, $mss2))
let $variants := $person/tei:persName[@type="variant"]
return if (count($mss) gt 0) then
<doc>
<field name="type">person</field>
<field name="pk">{ $id }</field>
<field name="id">{ $id }</field>
<field name="title">{ $name }</field>
<field name="alpha_title">{ bod:alphabetize($name) }</field>
<field name="pp_name_s">{ $name }</field>
{
for $variant in $variants
let $vname := normalize-space($variant/string())
order by $vname
return <field name="pp_variant_sm">{ $vname }</field>
}
{
let $roles := distinct-values(
(
$collection//tei:persName[@key = $id]/ancestor::editor[1]/@role/tokenize(., ' '),
$collection//tei:persName[@key = $id]/@type/tokenize(., ' '),
if ($isauthor) then 'author' else ()
)
)[not(. = ('alt','standard','unknown','desc','ment','wit','par','heb','beg','head','end','acr','ara','col'))] (: TODO: Find out what these mean and map them to something? :)
for $role in $roles
order by $role
return <field name="pp_roles_sm">{ bod:personRoleLookup($role) }</field>
}
{
for $ms in $mss
order by $ms
return <field name="link_manuscripts_smni">{ $ms }</field>
}
</doc>
else
()
}
</add>