index-processor.xqm 41.5 KB
Newer Older
Mathias Goebel's avatar
Mathias Goebel committed
1
xquery version "3.1";
Mathias Goebel's avatar
Mathias Goebel committed
2
3
(:~
: This module prepares the index html.
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
4
5
6
: It is used for preparing a cached version and also called when preparing
: the index for a single notebook.
: The corresponding viewer module is `index-viewer.xqm`.
Mathias Goebel's avatar
Mathias Goebel committed
7
8
9
10
: @author Mathias Göbel
: @version 1.0
: @see https://fontane-nb.dariah.eu/register.html
:)
Mathias Goebel's avatar
Mathias Goebel committed
11
module namespace f-indexproc="http://fontane-nb.dariah.eu/indexproc";
12
import module namespace f-misc="http://fontane-nb.dariah.eu/ns/SADE/misc" at "misc.xqm";
13
import module namespace code="http://bdn-edition.de/ns/code-view";
14

15
declare namespace gndo="http://d-nb.info/standards/elementset/gnd#";
Mathias Goebel's avatar
Mathias Goebel committed
16
17
declare namespace ore="http://www.openarchives.org/ore/terms/";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
Mathias Goebel's avatar
Mathias Goebel committed
18
declare namespace tei="http://www.tei-c.org/ns/1.0";
Mathias Goebel's avatar
Mathias Goebel committed
19
declare namespace tgmd="http://textgrid.info/namespaces/metadata/core/2010";
Mathias Goebel's avatar
Mathias Goebel committed
20
declare namespace xhtml="http://www.w3.org/1999/xhtml";
Mathias Goebel's avatar
Mathias Goebel committed
21

Mathias Goebel's avatar
Mathias Goebel committed
22
23
declare variable $f-indexproc:metaCollection := '/db/sade-projects/textgrid/data/xml/meta/';
declare variable $f-indexproc:targetStart := "http://textgridrep.org/textgrid:";
Mathias Goebel's avatar
   
Mathias Goebel committed
24
25
26
27
(: try/catch here, to pass the tests when no request object is available :)
declare variable $f-indexproc:getEntity := try {request:get-parameter('e', '')} catch * {""};
declare variable $f-indexproc:getIndex := try {request:get-parameter('i', '')} catch * {""};
declare variable $f-indexproc:notebookParam := try {request:get-parameter('nb', '')} catch * {""};
Mathias Goebel's avatar
Mathias Goebel committed
28
29
30
31
32
declare variable $f-indexproc:getNotebook := $f-indexproc:targetStart || $f-indexproc:notebookParam;

declare variable $f-indexproc:dataPath := '/db/sade-projects/textgrid/data/xml/data/';
declare variable $f-indexproc:dataCollection := collection($f-indexproc:dataPath);

33
34
35
36
declare variable $f-indexproc:BeaconMap := map:merge((
        local:beacon-parser(xs:anyURI("http://www.historische-kommission-muenchen-editionen.de/beacon_ndb.txt")),
        local:beacon-parser(xs:anyURI("http://www.historische-kommission-muenchen-editionen.de/beacon_adb.txt"))
        ));
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
37
38
39
(:~
 : Helper function to collect all main nodes from the index files.
:)
Mathias Goebel's avatar
Mathias Goebel committed
40
declare function local:getNodes()
Mathias Goebel's avatar
   
Mathias Goebel committed
41
as array(*) {
Mathias Goebel's avatar
Mathias Goebel committed
42
43
44
45
46
47
let $agg := '253st.xml' (: TextGrid Aggregation containing all index files :)
let $uris := (doc('/db/sade-projects/textgrid/data/xml/agg/' || $agg)
          //ore:aggregates/substring-after(@rdf:resource, 'textgrid:')
        )[. != "25547"] (: omit the bibliography here :)
let $docs := $uris ! doc($f-indexproc:dataPath || . || '.xml')

Mathias Goebel's avatar
   
Mathias Goebel committed
48
return
Mathias Goebel's avatar
Mathias Goebel committed
49
    [
Mathias Goebel's avatar
Mathias Goebel committed
50
    $docs//tei:body/tei:listEvent,
Mathias Goebel's avatar
Mathias Goebel committed
51
    $docs//tei:body/tei:listOrg,
Mathias Goebel's avatar
Mathias Goebel committed
52
53
54
55
    $docs//tei:body/tei:listPerson,
    $docs//tei:body/tei:listPlace,
    $docs//tei:body//tei:list[@type="works"],
    $docs//tei:body//tei:list[@type="periodicals"],
Mathias Goebel's avatar
   
Mathias Goebel committed
56
    $docs//tei:body//tei:list[@type="Fontane"]
Mathias Goebel's avatar
Mathias Goebel committed
57
    ]
Mathias Goebel's avatar
Mathias Goebel committed
58
59
60
};

(:~
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
61
62
63
64
65
66
67
 : the list type an entity is listed in.
 : This is used when preparing the html resource name.
 : @param $entity – on of tei:item, tei:place, tei:person, tei:gersonGrp,
 : tei:event or tei:org
 : @return on of listEvent, listOrg, listPlace, listPerson, list-works,
 : list-Fontane, list-periodicals
 :)
Mathias Goebel's avatar
Mathias Goebel committed
68
69
70
71
72
declare function local:get-list-by-entity($entity as node())
as xs:string {
switch ( $entity/local-name() )
    case "event" return "listEvent"
    case "org" return "listOrg"
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
73
    case "person" return
Mathias Goebel's avatar
Mathias Goebel committed
74
75
76
        if($entity/ancestor::tei:item)
        then local:get-list-by-entity( $entity/ancestor::tei:item[last()] )
        else "listPerson"
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
77
    case "personGrp" return
Mathias Goebel's avatar
Mathias Goebel committed
78
79
80
81
82
83
84
85
86
87
        if($entity/ancestor::tei:item)
        then local:get-list-by-entity( $entity/ancestor::tei:item[last()] )
        else "listPerson"
    case "place" return "listPlace"
    default return
        let $list := ($entity/ancestor::tei:list[@type])[last()]
        return
            $list/local-name() || "-" || string($list/@type)
};

Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
88
89
90
(:~
 : Helper function to use an efficient map data type to store the model.
 :)
Mathias Goebel's avatar
Mathias Goebel committed
91
declare function local:main-map($index as xs:string+)
Mathias Goebel's avatar
Mathias Goebel committed
92
as map() {
Mathias Goebel's avatar
Mathias Goebel committed
93
94
let $nodes := local:getNodes()
return
Mathias Goebel's avatar
Mathias Goebel committed
95
map:new(
Mathias Goebel's avatar
Mathias Goebel committed
96
97
    for $n in 1 to array:size($nodes)
    let $node := $nodes?($n)
Mathias Goebel's avatar
Mathias Goebel committed
98
99
    let $localId := string-join(($node/local-name(), $node/@type), "-")
    let $content :=
Mathias Goebel's avatar
Mathias Goebel committed
100
        for $node in $node return
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
101
        switch ($node/local-name())
Mathias Goebel's avatar
   
Mathias Goebel committed
102
103
104
105
106
107
108
109
110
            case "listEvent" return
                if($index = "listEvent") then f-indexproc:events($node) else ()
            case "listOrg" return
                if($index = "listOrg") then f-indexproc:orgs($node) else ()
            case "listPerson" return
                if($index = "listPerson") then f-indexproc:persons($node) else ()
            case "listPlace" return
                if($index = "listPlace") then f-indexproc:places($node) else ()
            case "list" return
Mathias Goebel's avatar
Mathias Goebel committed
111
                f-indexproc:works($node)
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
112
            default return error(QName("FONTANE", "INDEX1"), "unknown node-name: " || $node/local-name())
Mathias Goebel's avatar
Mathias Goebel committed
113
114
115
116
    return
        map:entry(
            $localId,
            map:new((
Mathias Goebel's avatar
Mathias Goebel committed
117
                map:entry("content", $content)
Mathias Goebel's avatar
Mathias Goebel committed
118
119
120
121
122
            ))
        )
    )
};

Mathias Goebel's avatar
   
Mathias Goebel committed
123
124
125
126
127
declare function local:main-map()
as map() {
    local:main-map(("listEvent", "listOrg", "listPerson", "listPlace", "list-"))
};

Mathias Goebel's avatar
Mathias Goebel committed
128
129
130
131
132
(:~
 : Main function to create a complete index, contains some template specific
 : code.
 :   :)
declare function f-indexproc:register()
Mathias Goebel's avatar
Mathias Goebel committed
133
as element(xhtml:div)+ {
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
134
let $map := local:main-map()
Mathias Goebel's avatar
Mathias Goebel committed
135
return
Mathias Goebel's avatar
   
Mathias Goebel committed
136
    $map?*?("content")
Mathias Goebel's avatar
Mathias Goebel committed
137
};
Mathias Goebel's avatar
Mathias Goebel committed
138

Mathias Goebel's avatar
   
Mathias Goebel committed
139
140
141
142
143
144
145
146
147
148
(:~
 : Main function to create a complete index, contains some template specific
 : code.
 :   :)
declare function f-indexproc:register($index as xs:string?)
as element(xhtml:div)+ {
let $map := local:main-map($index)
return
    $map?*?("content")
};
149

Mathias Goebel's avatar
Mathias Goebel committed
150
151
152
153
154
(:~
 : helper function to get the tgmd:title by URI
 : @param – $uri the textgrid-URI without prefix
 : TODO: may this function should be placed in a generic module
 :  :)
Mathias Goebel's avatar
Mathias Goebel committed
155
156
declare function local:resolve-name($uri as xs:string)
as xs:string {
Mathias Goebel's avatar
   
Mathias Goebel committed
157
    let $title := string(doc($f-indexproc:metaCollection || $uri || '.xml')//tgmd:title)
Mathias Goebel's avatar
Mathias Goebel committed
158
    return
Mathias Goebel's avatar
   
Mathias Goebel committed
159
160
161
        if($title = "")
        then $uri
        else $title
Mathias Goebel's avatar
Mathias Goebel committed
162
163
164
};

(:~
Mathias Goebel's avatar
Mathias Goebel committed
165
 : tests for a given ID to appear in all @xml:id in a given node
Mathias Goebel's avatar
Mathias Goebel committed
166
167
168
 : @param – $id the id to search for
 : @param – $node the document or xml fragment
 : :)
169
170
declare function local:check-active($id as xs:string, $node as element(*)+)
as xs:boolean {
171
    exists($node/id($id))
Mathias Goebel's avatar
Mathias Goebel committed
172
173
};

Mathias Goebel's avatar
Mathias Goebel committed
174
175
176
177
(:~
 : checks if a target entity is in the current node set
 : @param $node – any node set
 :   :)
Mathias Goebel's avatar
Mathias Goebel committed
178
179
declare function local:check-entity($node as node()+)
as xs:string? {
Mathias Goebel's avatar
Mathias Goebel committed
180
    if(local:check-active($f-indexproc:getEntity, $node))
Mathias Goebel's avatar
Mathias Goebel committed
181
182
183
184
    then "active"
    else ()
};

185
186
(:~
 : creates a generic xhtml:class attribute mandatory for every entry
Mathias Goebel's avatar
Mathias Goebel committed
187
 : @param $id – ID to check for
188
 :  :)
Mathias Goebel's avatar
Mathias Goebel committed
189
declare function local:entry-class($id as attribute(xml:id))
Mathias Goebel's avatar
Mathias Goebel committed
190
as attribute(class)? {
191
192
    attribute class {
        "registerEintrag",
Mathias Goebel's avatar
Mathias Goebel committed
193
        $id/parent::*/local-name()
194
195
196
197
    }
};

(:~
Mathias Goebel's avatar
Mathias Goebel committed
198
199
200
 : creates a list for label or name
 : @param $variant – a tei element containing any secondary label or name variant
 :)
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
declare function local:variant($variant as element()*)
as element(xhtml:li)? {
if(not(exists($variant))) then () else
    element xhtml:li {
        attribute class { "variant" },
        "Im Text: ",
        element xhtml:ul {
            for $var at $pos in $variant
            return
                element xhtml:li {
                    string($var) || (if($pos = count($variant)) then () else ",")
                }
        }
    }
};

(:~
218
 : transforms tei:idno to xhtml:li
Mathias Goebel's avatar
Mathias Goebel committed
219
 : @param $idnos – tei element (idno and label) with reference to authority file
220
221
222
 : TODO: declare element(tei:idno), currently wrong encoding with tei:label
 :  :)
declare function local:idno($idnos as element()*)
Mathias Goebel's avatar
Mathias Goebel committed
223
as element(xhtml:li)* {
224
225
226
227
228
229
230
231
232
233
for $idno in $idnos
let $str := string($idno)
return
    element xhtml:li {
        attribute class {"idno"},
        string($idno/@type) || ": " || $str,
        " ",
        element xhtml:a {
            attribute href { string($idno/@xml:base) || $str },
            <xhtml:i title="Link zu externer Ressource" class="fa fa-external-link"></xhtml:i>
234
235
236
237
238
239
240
241
242
243
244
        },
        (: ADB :)
        if($idno/parent::tei:person and $f-indexproc:BeaconMap($str))
        then
          (",&#160;",
            let $url := $f-indexproc:BeaconMap($str)
            return
              element xhtml:a {
                attribute title {
                    if(ends-with($url, "adbcontent"))
                    then "ADB-Eintrag basierend auf GND"
Mathias Goebel's avatar
Mathias Goebel committed
245
                    else "NDB-Eintrag basierend auf GND"
246
247
248
249
250
251
252
                },
                attribute href {$url},
                if(ends-with($url, "adbcontent"))
                then "ADB"
                else "NDB"
            })
        else ()
253
254
255
256
257
258
259
    }
};

(:~
 : transformation from tei:note to xhtml:li
 :  :)
declare function local:note($note as element(tei:note)*)
Mathias Goebel's avatar
Mathias Goebel committed
260
as element(xhtml:li)* {
261
262
263
264
for $n in $note
    return
        element xhtml:li {
            attribute class { "tei-note" },
Mathias Goebel's avatar
Mathias Goebel committed
265
266
267
268
269
270
271
            $n/text(),
            for $ptr in $n/tei:ptr[@type = "Figurenlexikon"]
            return
                element xhtml:a {
                    attribute href { string($ptr/@target) },
                    string($n/@type)
                }
272
273
274
        }
};

275
276
277
278
279
(:~
 : creates a list of all creations or points to the creator of a work
 : :)
declare function local:creator($creators as element(tei:link)+)
as element(xhtml:li) {
280
281
282
283
284
285

if($creators[1]/parent::*/parent::tei:person)
then
    (: person item that is the creator :)
element xhtml:li {
    attribute class { "creator" },
Mathias Goebel's avatar
Mathias Goebel committed
286
    "",
287
    element xhtml:ul {
288
        attribute class {"workList"},
289
290
291
292
293
294
295
296
297
298
299
300
301
302
        for $creator in $creators
        let $target := $creator/@target => substring-before(" ")
        let $targetId := $target => substring-after(":")
        let $targetNode := $f-indexproc:dataCollection/id($targetId)
        let $htmlResource :=
(: TODO remove condition_s_ for final production release :)
            if($targetNode)
            then
                if($targetNode[2])
                then "two entities with same ID: " || $targetId
                else local:get-list-by-entity( $targetNode )
            else "target-not-available"
        return
            element xhtml:li {
303
                attribute class {"item"},
304
305
306
307
308
                element xhtml:a {
                    attribute href { "register-" || $htmlResource || ".html?e=" || string-join($targetId) },
                    if($targetNode[2])
                    then "two entities with same ID: " || $targetId
                    else string($targetNode/*[1])
309
                },
Mathias Goebel's avatar
fix    
Mathias Goebel committed
310
                text{ "&#8195;" },
311
312
313
314
315
316
317
                element xhtml:span {
                    attribute class { "load-entity" },
                    attribute data-load { $targetId },
                    element xhtml:i {
                        attribute class {"fa fa-plus-square-o"},
                        attribute aria-hidden {"true"}
                    }
318
319
320
321
322
323
                }
            }
    }
}
else
    (: work item with creator :)
324
325
element xhtml:li {
    attribute class { "creator" },
Mathias Goebel's avatar
Mathias Goebel committed
326
    "",
327
    element xhtml:ul {
Mathias Goebel's avatar
Mathias Goebel committed
328
        attribute class {"listPerson"},
329
330
        for $creator in $creators
        let $target := $creator/@target => substring-after(" ")
Mathias Goebel's avatar
Mathias Goebel committed
331
        let $targetId := $target => substring-after(":")
332
        let $targetNode := $f-indexproc:dataCollection/id($targetId)
Mathias Goebel's avatar
   
Mathias Goebel committed
333
334
335
        let $htmlResource :=
(: TODO remove condition for final production release :)
            if($targetNode)
336
337
338
339
            then
                if($targetNode[2])
                then "two entities with same ID: " || $targetId
                else local:get-list-by-entity( $targetNode )
Mathias Goebel's avatar
   
Mathias Goebel committed
340
            else "target-not-available"
341
342
        return
            element xhtml:li {
Mathias Goebel's avatar
Mathias Goebel committed
343
                attribute class {"person"},
344
                element xhtml:a {
345
346
347
348
                    attribute href { "register-" || $htmlResource || ".html?e=" || string-join($targetId) },
                    if($targetNode[2])
                    then "two entities with same ID: " || $targetId
                    else string($targetNode/*[1])
349
350
351
352
353
354
                }
            }
    }
}
};

355
356
357
declare function local:has-former-or-current-location($links as element(tei:link)*)
as element(xhtml:li)* {
for $link in $links
358
359
let $id := $link/@target => substring-after(" ") => substring-after(":")
let $targetNode := $f-indexproc:dataCollection/id($id)
360
361
362
363
364
365
366
return
    element xhtml:li {
        attribute class { "former-or-current-location" },
        element xhtml:a {
        attribute href { "?e=" || $id },
        <xhtml:i class="fa fa-map-marker" aria-hidden="true"></xhtml:i>,
        "&#160;",
367
368
369
370
371
372
373
374
        $targetNode/*[1]/string(),
        let $ancestors := $targetNode/ancestor::tei:place
        for $parentPlace at $pos in $ancestors
        let $name := $parentPlace/*[1]/string()
        return
          ((if($pos = 1) then "(" else ", ") ||
          $name ||
          (if($pos = count($ancestors)) then ")" else ()))
375
376
377
378
        }
    }
};

379
380
(:~
 : a list item with a list of links
Mathias Goebel's avatar
Mathias Goebel committed
381
 :)
Mathias Goebel's avatar
Mathias Goebel committed
382
declare function local:links($links as element(tei:link)*)
Mathias Goebel's avatar
Mathias Goebel committed
383
as element(xhtml:li) {
Mathias Goebel's avatar
Mathias Goebel committed
384
let $notebookUris := $links ! (substring-after(./@target, $f-indexproc:targetStart) => substring(1,5) => distinct-values())
Mathias Goebel's avatar
Mathias Goebel committed
385
386
387
388
389
390
391
392
393
394
395
396
397
let $linkMap as map() :=
    map:new(
        for $nb in $notebookUris
        return
            map:entry($nb, $links[contains(@target, $nb)])
    )
return
    element xhtml:li {
        attribute class { "links" },
        if(count(map:keys($linkMap)) lt 2) then 'In Notizbuch' else 'In den Notizbüchern',
        element xhtml:ul {
            local:link($linkMap)
        }
398
399
400
401
402
403
404
    }
};

(:~
 : create list items containing links
 :   :)
declare function local:link($map as map()*)
Mathias Goebel's avatar
Mathias Goebel committed
405
as element(xhtml:li)* {
406
407
    for $tguri in map:keys($map)
    let $resolve := local:resolve-name($tguri)
Mathias Goebel's avatar
   
Mathias Goebel committed
408
    order by $resolve
409
410
    return
        element xhtml:li {
Mathias Goebel's avatar
   
Mathias Goebel committed
411
            replace($resolve, "([A-E])0(\d)", "$1$2") || ": ",
412
413
            element xhtml:ul {
                attribute class {"link-list-horizontal"},
414
415
416
                let $this-map := $map($tguri)
                let $surface-sequence := $this-map ! (./@target => substring-after("surface[@n='") => substring-before("']//"))
                for $link at $pos in $this-map
417
                let $page := $link/@target => substring-after("surface[@n='") => substring-before("']//")
418
419
420
                let $index-of := index-of($surface-sequence, $page)
                let $count := count( $index-of )
                where $pos = $index-of[1]
421
422
423
424
425
426
                return
                    element xhtml:li {
                        element xhtml:a {
                            attribute href {
                                "edition.html?id=%2Fxml%2Fdata%2F" || $tguri
                                || ".xml&amp;page=" || $page
427
                                || "&amp;target=" || string($link/parent::tei:*/parent::tei:*/@xml:id)
428
                            },
429
430
431
                            f-misc:n-translate($page),
                            if($count eq 1) then ()
                            else (" ", <xhtml:span title="Anzahl an Vorkommnissen auf dieser Seite">({$count})</xhtml:span>)
432
433
434
435
436
437
                        }
                    }
            }
        }
};

Mathias Goebel's avatar
Mathias Goebel committed
438
439
(:~
 : prepares a link to the current entry
Mathias Goebel's avatar
Mathias Goebel committed
440
 : @param $id – the xml:id of the currently processed element
Mathias Goebel's avatar
Mathias Goebel committed
441
:)
Mathias Goebel's avatar
Mathias Goebel committed
442
declare function local:entry-link($id as attribute(xml:id))
Mathias Goebel's avatar
Mathias Goebel committed
443
444
445
446
447
as element(xhtml:span) {
    element xhtml:span {
        attribute class {"registerLink"},
        element xhtml:a {
            attribute href {
Mathias Goebel's avatar
Mathias Goebel committed
448
                "register-" || local:get-list-by-entity($id/parent::*) || ".html?e=" || $id
Mathias Goebel's avatar
Mathias Goebel committed
449
450
451
452
453
454
                },
            <xhtml:i title="Link zu diesem Eintrag" class="fa fa-link"></xhtml:i>
        }
    }
};

Mathias Goebel's avatar
Mathias Goebel committed
455
456
457
458
(:~
 : creates a xhtml list item containing serialized code.
 : @param $node – a single element
 :   :)
Mathias Goebel's avatar
Mathias Goebel committed
459
460
declare function local:li-code($node as element(*))
as element(xhtml:li) {
461
462
463
464
element xhtml:li {
    attribute class {"register-code"},
    element xhtml:span {
        attribute class {"registerCode"},
Mathias Goebel's avatar
Mathias Goebel committed
465
466
            <xhtml:i title="Zeige XML" class="fa fa-code"></xhtml:i>
    },
467
468

    code:main($node)
Mathias Goebel's avatar
Mathias Goebel committed
469
}
Mathias Goebel's avatar
Mathias Goebel committed
470
471
};

472
473
474
475
476
(:~
 : generic function for entries with tei:note/tei:ptr.
 : @return link to the corresponding index entry
 :   :)
declare function local:pointer($entry as element())
Mathias Goebel's avatar
Mathias Goebel committed
477
as element(xhtml:li) {
Mathias Goebel's avatar
Mathias Goebel committed
478
    let $labelMain := ($entry/*)[1]
479
    let $target := $entry/tei:note/tei:ptr/@target => substring-after('#')
Mathias Goebel's avatar
Mathias Goebel committed
480
    let $targetNode := $f-indexproc:dataCollection/id($target)
481
482
483
484
    return
        element xhtml:li {
            attribute class {
                "registerEintrag",
Mathias Goebel's avatar
Mathias Goebel committed
485
                if( $entry >> $targetNode )
486
487
488
489
490
                then "up"
                else "down"
            },
            element xhtml:span {
                    attribute class { "label-main" },
Mathias Goebel's avatar
Mathias Goebel committed
491
                    $labelMain/text()
492
493
494
495
496
497
498
            },
            element xhtml:ul {
                element xhtml:li {
                attribute class { "pointer" },
                "siehe: ",
                    element xhtml:a {
                        attribute href { "?e=" || $target },
499
500
501
                        try {
                             string($targetNode/*[1])
                         } catch * {
Mathias Goebel's avatar
Mathias Goebel committed
502
                             (: TODO remove try catch when the data is better :)
503
504
                             "multiple entities found: " || string-join(($targetNode ! serialize(.)), " AND ")
                         }
505
506
507
508
509
                    }
                }
            }
        }
};
510

Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
511
512
513
(:
 : parses a tei:bibl and mainly prepares a list item with a link to the entity
 :)
514
515
516
517
declare function local:bibl($bibls as element(tei:bibl)*)
as element(xhtml:li)* {
for $bibl in $bibls
    let $biblId := $bibl/tei:ptr/@target => substring-after(":")
Mathias Goebel's avatar
Mathias Goebel committed
518
    let $targetNode := $f-indexproc:dataCollection/id($biblId)[. instance of element(tei:bibl)]
519
520
521
522
523
524
525
    return
        element xhtml:li {
            attribute class { "bibl" },
            element xhtml:a {
            attribute href { "literaturvz.html?id=" || $biblId },
            <xhtml:i class="fa fa-book" aria-hidden="true"></xhtml:i>,
            "&#160;",
Mathias Goebel's avatar
Mathias Goebel committed
526
            $targetNode/tei:choice/tei:abbr/string() ||
527
528
529
530
531
532
533
            (if($bibl/tei:citedRange)
            then ":&#160;" || $bibl/tei:citedRange
            else ())
            }
        }
};

534
535
536
537
538
539
540
541
542
declare function local:get-gnd-data($url as xs:string)
as element(rdf:RDF){
httpclient:get(xs:anyURI($url || "/about/rdf"), false(), ())//rdf:RDF
};

(: ################################################### :)
(: ################################################### :)
(: ################################################### :)

Mathias Goebel's avatar
Mathias Goebel committed
543
544
(:~
 : parser for listEvents/event entities
545
 : @param $eventDoc – the tei:listEvent containing all entries
Mathias Goebel's avatar
Mathias Goebel committed
546
 :  :)
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
547
declare function f-indexproc:events($eventDoc as element(tei:listEvent))
548
as element(xhtml:div) {
Mathias Goebel's avatar
   
Mathias Goebel committed
549
<xhtml:div id="{ string-join(($eventDoc/local-name(), $eventDoc/@type), "-") }" class="tab-pane">
Mathias Goebel's avatar
Mathias Goebel committed
550
    <xhtml:div class="panel-group" aria-multiselectable="true" role="tablist">
551
552
    {for $eventList in $eventDoc/tei:listEvent
    return
Mathias Goebel's avatar
Mathias Goebel committed
553
554
        <xhtml:div class="panel panel-default">
            <xhtml:div class="panel-heading">
555
                <h4 class="panel-title">{$eventList/tei:head/text()}</h4>
Mathias Goebel's avatar
Mathias Goebel committed
556
557
            </xhtml:div>
            <xhtml:div class="panel-body">
Mathias Goebel's avatar
Mathias Goebel committed
558
                <ul class="listEvent">
559
{
Mathias Goebel's avatar
Mathias Goebel committed
560
if($f-indexproc:getNotebook = $f-indexproc:targetStart)
Mathias Goebel's avatar
Mathias Goebel committed
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
then
  for $event in $eventList/tei:event
  let $sort := string($event/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-event($event)
else
  for $event in $eventList/tei:event[tei:linkGrp/tei:link
  [starts-with(@target, $f-indexproc:getNotebook)]]
  let $sort := string($event/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-event($event)
578
}
Mathias Goebel's avatar
Mathias Goebel committed
579
                </ul>
Mathias Goebel's avatar
Mathias Goebel committed
580
581
            </xhtml:div>
        </xhtml:div>
582
    }
Mathias Goebel's avatar
Mathias Goebel committed
583
584
    </xhtml:div>
</xhtml:div>
Mathias Goebel's avatar
Mathias Goebel committed
585
586
};

587
declare function local:prepare-event($event as element(tei:event))
588
as element(xhtml:li) {
589
590
591
592
593
594
595
(: check if the item points to another entity :)
if( not(exists($event/@xml:id)) )
then
    (: pointer :)
    local:pointer($event)
else
    let $id := $event/@xml:id
Mathias Goebel's avatar
Mathias Goebel committed
596
    let $wheres := tokenize($event/@where, " ") ! substring-after(., ":")
597
598
599
600
601
602
    let $labelMain := ($event/tei:label)[1]
    let $labelAlt := ($event/tei:label[not(@type="variant")])[position() gt 1]
    let $variant := $event/tei:label[@type="variant"]
    let $note := $event/tei:note
    let $bibl := $event/tei:bibl
    let $links := $event/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
Mathias Goebel's avatar
Mathias Goebel committed
603
return
604
605
606
    element xhtml:li {
        attribute id { string($id) },
        local:entry-class($id),
Mathias Goebel's avatar
Mathias Goebel committed
607
        (: link to this entry :)
Mathias Goebel's avatar
Mathias Goebel committed
608
        local:entry-link($id),
609
610
        element xhtml:span {
                attribute class { "label-main" },
Mathias Goebel's avatar
Mathias Goebel committed
611
                $labelMain/text()
Mathias Goebel's avatar
Mathias Goebel committed
612
            },
613
        element xhtml:ul {
Mathias Goebel's avatar
Mathias Goebel committed
614
            (: variant :)
615
            local:variant($variant),
Mathias Goebel's avatar
Mathias Goebel committed
616
            (: secondary label :)
Mathias Goebel's avatar
Mathias Goebel committed
617
            local:idno($labelAlt),
Mathias Goebel's avatar
Mathias Goebel committed
618
            (: note :)
619
            local:note($note),
Mathias Goebel's avatar
Mathias Goebel committed
620
            (: where :)
Mathias Goebel's avatar
Mathias Goebel committed
621
            for $where in $wheres return
622
623
624
            element xhtml:li {
                attribute class { "where" },
                element xhtml:a {
Mathias Goebel's avatar
Mathias Goebel committed
625
                attribute href { "register-listPlace.html?e="|| $where },
Mathias Goebel's avatar
Mathias Goebel committed
626
627
                <xhtml:i class="fa fa-map-marker" aria-hidden="true"></xhtml:i>,
                "&#160;",
Mathias Goebel's avatar
Mathias Goebel committed
628
                $f-indexproc:dataCollection/id($where)/*[1]/string()
Mathias Goebel's avatar
Mathias Goebel committed
629
630
631
                }
            },
            (: bibl :)
632
            local:bibl($bibl),
Mathias Goebel's avatar
Mathias Goebel committed
633
            (: links :)
Mathias Goebel's avatar
Mathias Goebel committed
634
            local:links($links),
635
            local:li-code($event)
Mathias Goebel's avatar
Mathias Goebel committed
636
637
        }
    }
Mathias Goebel's avatar
Mathias Goebel committed
638
639
};

Mathias Goebel's avatar
Mathias Goebel committed
640
(:~
Mathias Goebel's avatar
Mathias Goebel committed
641
 : parser for tei:listOrg, returns the index of orgnaisations.
Mathias Goebel's avatar
Mathias Goebel committed
642
 :  :)
Mathias Goebel's avatar
   
Mathias Goebel committed
643
644
645
declare function f-indexproc:orgs($orgDoc as element(tei:listOrg)+) {
let $result :=
<xhtml:div id="{ string-join(($orgDoc/local-name(), $orgDoc/@type), "-") }" class="tab-pane">
Mathias Goebel's avatar
Mathias Goebel committed
646
    <xhtml:div class="panel-group" aria-multiselectable="true" role="tablist">
647
648
    {for $orgList in $orgDoc
    return
Mathias Goebel's avatar
Mathias Goebel committed
649
650
        <xhtml:div class="panel panel-default">
            <xhtml:div class="panel-heading">
651
                <h4 class="panel-title">{ $orgList/tei:head/text() }</h4>
Mathias Goebel's avatar
Mathias Goebel committed
652
653
            </xhtml:div>
            <xhtml:div class="panel-body">
Mathias Goebel's avatar
Mathias Goebel committed
654
                <ul class="listOrg">
655
{
Mathias Goebel's avatar
Mathias Goebel committed
656
if($f-indexproc:getNotebook = $f-indexproc:targetStart)
Mathias Goebel's avatar
Mathias Goebel committed
657
658
659
660
661
662
663
664
then
  for $org in $orgList/tei:org
  let $sort := string($org/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-org($org)
Mathias Goebel's avatar
   
Mathias Goebel committed
665
else
Mathias Goebel's avatar
Mathias Goebel committed
666
667
668
669
670
671
672
  for $org in $orgList/tei:org[tei:linkGrp/tei:link[starts-with(@target, $f-indexproc:getNotebook)]]
  let $sort := string($org/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-org($org)
673
}
Mathias Goebel's avatar
Mathias Goebel committed
674
                </ul>
Mathias Goebel's avatar
Mathias Goebel committed
675
676
            </xhtml:div>
        </xhtml:div>
677
    }
Mathias Goebel's avatar
Mathias Goebel committed
678
679
    </xhtml:div>
</xhtml:div>
Mathias Goebel's avatar
   
Mathias Goebel committed
680
681
return
    $result
Mathias Goebel's avatar
Mathias Goebel committed
682
683
};

Mathias Goebel's avatar
Mathias Goebel committed
684
685
686
687
(:~
 : transforms a single tei:org element to a xhtml:li
 : @since 1.0
 :  :)
Mathias Goebel's avatar
Mathias Goebel committed
688
689
declare function local:prepare-org($org as element(tei:org))
as element(xhtml:li) {
690
691
692
693
694
695
(: check if the item points to another entity :)
if( not(exists($org/@xml:id)) )
then
    (: pointer :)
    local:pointer($org)
else
Mathias Goebel's avatar
Mathias Goebel committed
696
    let $id := $org/@xml:id
Mathias Goebel's avatar
Mathias Goebel committed
697
    let $labelMain := ($org/tei:orgName)[1]
Mathias Goebel's avatar
Mathias Goebel committed
698
    let $idnos := $org/tei:idno
Mathias Goebel's avatar
Mathias Goebel committed
699
    let $variant := $org/tei:orgName[@type="variant"]
Mathias Goebel's avatar
Mathias Goebel committed
700
701
702
703
    let $note := $org/tei:note
    let $bibl := $org/tei:bibl
    let $links := $org/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
return
704
705
706
    element xhtml:li {
        attribute id { string($id) },
        local:entry-class($id),
Mathias Goebel's avatar
Mathias Goebel committed
707
        (: link to this entry :)
Mathias Goebel's avatar
Mathias Goebel committed
708
        local:entry-link($id),
709
710
        element xhtml:span {
                attribute class { "label-main" },
Mathias Goebel's avatar
Mathias Goebel committed
711
                $labelMain/text()
Mathias Goebel's avatar
Mathias Goebel committed
712
            },
713
        element xhtml:ul {
Mathias Goebel's avatar
Mathias Goebel committed
714
            (: variant :)
715
            local:variant($variant),
Mathias Goebel's avatar
Mathias Goebel committed
716
            (: secondary label :)
Mathias Goebel's avatar
Mathias Goebel committed
717
            local:idno($idnos),
Mathias Goebel's avatar
Mathias Goebel committed
718
            (: note :)
719
            local:note($note),
Mathias Goebel's avatar
Mathias Goebel committed
720
            (: bibl :)
721
            local:bibl($bibl),
Mathias Goebel's avatar
Mathias Goebel committed
722
            (: links :)
Mathias Goebel's avatar
Mathias Goebel committed
723
            local:links($links),
Mathias Goebel's avatar
Mathias Goebel committed
724
            local:li-code($org)
Mathias Goebel's avatar
Mathias Goebel committed
725
726
        }
    }
Mathias Goebel's avatar
Mathias Goebel committed
727
728
};

Mathias Goebel's avatar
Mathias Goebel committed
729
(:~
Mathias Goebel's avatar
Mathias Goebel committed
730
 : parser for tei:listPerson, returns the index of persons
Mathias Goebel's avatar
Mathias Goebel committed
731
 :   :)
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
732
declare function f-indexproc:persons($persDoc as element(tei:listPerson))
Mathias Goebel's avatar
Mathias Goebel committed
733
as element(xhtml:div) {
Mathias Goebel's avatar
Mathias Goebel committed
734
(: main tab :)
Mathias Goebel's avatar
   
Mathias Goebel committed
735
<xhtml:div id="{ string-join(($persDoc/local-name(), $persDoc/@type), "-") }" class="tab-pane">
Mathias Goebel's avatar
Mathias Goebel committed
736
    <xhtml:div class="panel-group" aria-multiselectable="true" role="tablist">
737
738
    {for $persList in $persDoc
    return
Mathias Goebel's avatar
Mathias Goebel committed
739
740
        <xhtml:div class="panel panel-default">
            <xhtml:div class="panel-heading">
741
742
                <h4 class="panel-title"><a href="#collapse1-1" data-parent="#accordion" data-toggle="collapse">Personen und Werke</a>
                </h4>
Mathias Goebel's avatar
Mathias Goebel committed
743
744
            </xhtml:div>
            <xhtml:div class="panel-body">
Mathias Goebel's avatar
Mathias Goebel committed
745
                <ul class="listPerson">
746
{
Mathias Goebel's avatar
Mathias Goebel committed
747
if($f-indexproc:getNotebook = $f-indexproc:targetStart)
Mathias Goebel's avatar
Mathias Goebel committed
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
then
  for $pers in $persList/tei:*
  let $sort := string($pers/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-person($pers)
else
  for $pers in $persList/tei:*[tei:linkGrp/tei:link[starts-with(@target, $f-indexproc:getNotebook)]]
  let $sort := string($pers/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-person($pers)
764
}
Mathias Goebel's avatar
Mathias Goebel committed
765
                </ul>
Mathias Goebel's avatar
Mathias Goebel committed
766
767
            </xhtml:div>
        </xhtml:div>
768
    }
Mathias Goebel's avatar
Mathias Goebel committed
769
770
    </xhtml:div>
</xhtml:div>
Mathias Goebel's avatar
Mathias Goebel committed
771
772
};

Mathias Goebel's avatar
Mathias Goebel committed
773
774
declare function local:prepare-person($pers as element(*)+)
as element(xhtml:li) {
Mathias Goebel's avatar
Mathias Goebel committed
775
776
777
778
(: check if the item points to another entity :)
if( not(exists($pers/@xml:id)) )
then
    (: pointer :)
779
    local:pointer($pers)
Mathias Goebel's avatar
Mathias Goebel committed
780
781
782
else
    (: entity :)
    let $id := $pers/@xml:id
Mathias Goebel's avatar
Mathias Goebel committed
783
784
    let $labelMain := $pers/tei:persName[1]
    let $labelAlt := $pers/tei:persName[not(@type="variant")][position() gt 1]
Mathias Goebel's avatar
Mathias Goebel committed
785
    let $variant := $pers/tei:persName[@type="variant"]
Mathias Goebel's avatar
Mathias Goebel committed
786
787
788
789
790
791
792
    let $idnos := $pers/tei:idno
    let $birth := $pers/tei:birth
    let $death := $pers/tei:death
    let $occupation := $pers/tei:occupation
    let $state := $pers/tei:state/tei:desc
    let $note := $pers/tei:note
    let $bibl := $pers/tei:bibl
793
794
    let $members := $pers/tei:linkGrp/tei:link[@corresp="http://erlangen-crm.org/current/P107_has_current_or_former_member"]
    let $creator := $pers/tei:linkGrp/tei:link[@corresp="http://purl.org/dc/terms/creator"]
Mathias Goebel's avatar
Mathias Goebel committed
795
796
    let $links := $pers/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
    return
797
798
799
        element xhtml:li {
            attribute id { string($id) },
            local:entry-class($id),
Mathias Goebel's avatar
Mathias Goebel committed
800
            (: link to this entry :)
Mathias Goebel's avatar
Mathias Goebel committed
801
            local:entry-link($id),
802
803
            element xhtml:span {
                    attribute class { "label-main" },
Mathias Goebel's avatar
Mathias Goebel committed
804
                    $labelMain/text()
Mathias Goebel's avatar
Mathias Goebel committed
805
                },
806
            element xhtml:ul {
Mathias Goebel's avatar
Mathias Goebel committed
807
                (: variant :)
808
                local:variant($variant),
Mathias Goebel's avatar
Mathias Goebel committed
809
                (: secondary label :)
Mathias Goebel's avatar
Mathias Goebel committed
810
                for $l in $labelAlt
Mathias Goebel's avatar
Mathias Goebel committed
811
                return
812
813
                    element xhtml:li {
                    attribute class {"label-" || string($l/@type)},
Mathias Goebel's avatar
Mathias Goebel committed
814
815
816
817
818
                    $l/text(),
                    if($l/@type = "variant")
                    then ()
                    else (
                        "&#160;",
819
820
                        element xhtml:a {
                            attribute href { string($l/@xml:base) || string($l) },
Mathias Goebel's avatar
Mathias Goebel committed
821
822
823
824
825
                            <xhtml:i title="Link zu externer Ressource" class="fa fa-external-link"></xhtml:i>
                        }
                    )
                },
                (: idno :)
826
                local:idno($idnos),
Mathias Goebel's avatar
Mathias Goebel committed
827
828
                (: birth, death :)
                if( not($birth or $death) ) then () else
829
                    element xhtml:li {
Mathias Goebel's avatar
Mathias Goebel committed
830
831
832
833
834
835
836
                        if($birth) then ('&#8727;', $birth/text()) else (),
                        if( $birth and $death ) then " " else (),
                        if($death) then ('✝', $death/text()) else()
                    },
                (: occupation :)
                for $o in $occupation
                return
837
838
                    element xhtml:li {
                        attribute class { "occupation" },
Mathias Goebel's avatar
Mathias Goebel committed
839
840
841
842
                        $o/text()
                    },
                for $s in $state
                return
843
844
                    element xhtml:li {
                        attribute class { "state" },
Mathias Goebel's avatar
Mathias Goebel committed
845
846
                        $s/text()
                    },
847
848
849
850
851
852
853
854
855
856
857
858
859
860
                (: current or former member :)
                if(not(exists($members))) then () else
                element xhtml:li {
                    attribute class { "member" },
                    "Mitglieder:",
                    element xhtml:ul {
                        for $member in $members
                        let $memberId := $members/@target => substring-after(" ") => substring-after("#")
                        return
                            element xhtml:li {
                                element xhtml:a {
                                attribute href { "?e=" || $memberId },
                                <xhtml:i class="fa fa-user" aria-hidden="true"></xhtml:i>,
                                "&#160;",
Mathias Goebel's avatar
Mathias Goebel committed
861
                                $f-indexproc:dataCollection/id($memberId)/*[1]/string()
862
863
864
865
866
867
                                }
                            }
                    }
                },
                if (not(exists($creator))) then () else
                local:creator($creator),
Mathias Goebel's avatar
Mathias Goebel committed
868
                (: note :)
869
                local:note($note),
Mathias Goebel's avatar
Mathias Goebel committed
870
                (: bibl :)
871
                local:bibl($bibl),
Mathias Goebel's avatar
Mathias Goebel committed
872
                (: links :)
Mathias Goebel's avatar
Mathias Goebel committed
873
                local:links($links),
Mathias Goebel's avatar
Mathias Goebel committed
874
                local:li-code($pers)
Mathias Goebel's avatar
Mathias Goebel committed
875
876
877
878
            }
        }
};

Mathias Goebel's avatar
Mathias Goebel committed
879
880
881
(:~
 : prepares the index of geographical references
 :  :)
Mathias Goebel's avatar
cleanup    
Mathias Goebel committed
882
declare function f-indexproc:places($listPlace as element(tei:listPlace))
Mathias Goebel's avatar
Mathias Goebel committed
883
as element(xhtml:div) {
Mathias Goebel's avatar
   
Mathias Goebel committed
884
<xhtml:div id="{ string-join(($listPlace/local-name(), $listPlace/@type), "-") }" class="tab-pane">
Mathias Goebel's avatar
Mathias Goebel committed
885
886
887
    <xhtml:div class="panel-group" aria-multiselectable="true" role="tablist">
        <xhtml:div class="panel panel-default">
            <xhtml:div class="panel-heading">
888
889
                <h4 class="panel-title"><a href="#collapse1-1" data-parent="#accordion" data-toggle="collapse">Geographisches Register</a>
                </h4>
Mathias Goebel's avatar
Mathias Goebel committed
890
891
            </xhtml:div>
            <xhtml:div class="panel-body">
Mathias Goebel's avatar
Mathias Goebel committed
892
                <ul class="listPlace">
893
{
Mathias Goebel's avatar
Mathias Goebel committed
894
if($f-indexproc:getNotebook = $f-indexproc:targetStart)
Mathias Goebel's avatar
Mathias Goebel committed
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
then
  for $place in $listPlace/tei:place
  let $sort := string($place/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-place($place)

else
  for $place in $listPlace/tei:place
      [tei:linkGrp/tei:link
      [starts-with(@target, $f-indexproc:getNotebook)]]
  let $sort := string($place/*[1])
                => replace("ä", "ae")
                => replace("ö", "oe")
                => replace("ü", "ue")
  order by $sort
  return local:prepare-place($place)
914
}
Mathias Goebel's avatar
Mathias Goebel committed
915
                </ul>
Mathias Goebel's avatar
Mathias Goebel committed
916
917
918
919
            </xhtml:div>
        </xhtml:div>
    </xhtml:div>
</xhtml:div>
Mathias Goebel's avatar
Mathias Goebel committed
920
921
};

Mathias Goebel's avatar
Mathias Goebel committed
922
923
(:~
 : transformation of a single geographical reference item  :)
Mathias Goebel's avatar
Mathias Goebel committed
924
925
declare function local:prepare-place($place as element(tei:place))
as element(xhtml:ul) {
Mathias Goebel's avatar
Mathias Goebel committed
926
927
928
929
(: check if the item points to another entity :)
if( not(exists($place/@xml:id)) )
then
    (: pointer :)
930
    local:pointer($place)
Mathias Goebel's avatar
Mathias Goebel committed
931
932
933
else
    (: entity :)
    let $id := $place/@xml:id
Mathias Goebel's avatar
Mathias Goebel committed
934
935
    let $labelMain := $place/tei:placeName[1]
    let $labelAlt := $place/tei:placeName[not(@type="variant")][position() gt 1]
Mathias Goebel's avatar
Mathias Goebel committed
936
    let $variant := $place/tei:placeName[@type="variant"]
Mathias Goebel's avatar
Mathias Goebel committed
937
938
    let $idnos := $place/tei:idno
    let $note := $place/tei:note
939
    let $creator := $place/tei:linkGrp/tei:link[@corresp="http://purl.org/dc/terms/creator"]
Mathias Goebel's avatar
Mathias Goebel committed
940
    let $bibl := $place/tei:bibl
Mathias Goebel's avatar
Mathias Goebel committed
941
    let $tookPlaceAt := $place/tei:linkGrp/tei:link[@corresp="http://erlangen-crm.org/current/P7_took_place_at"]
942
    let $formerCurrentLocation := $place/tei:linkGrp/tei:link[@corresp="http://erlangen-crm.org/current/P53_has_former_or_current_location"]
Mathias Goebel's avatar
Mathias Goebel committed
943
944
    let $links := $place/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"]
    return
945
946
947
        element xhtml:li {
            attribute id { string($id) },
            local:entry-class($id),
Mathias Goebel's avatar
Mathias Goebel committed
948
            (: link to this entry :)
Mathias Goebel's avatar
Mathias Goebel committed
949
            local:entry-link($id),
950
951
            element xhtml:span {
                    attribute class { "label-main" },
Mathias Goebel's avatar
Mathias Goebel committed
952
                    $labelMain/text()
Mathias Goebel's avatar
Mathias Goebel committed
953
                },
954
            element xhtml:ul {
Mathias Goebel's avatar
Mathias Goebel committed
955
                (: variant :)
956
                local:variant($variant),
Mathias Goebel's avatar
Mathias Goebel committed
957
                (: secondary label :)
Mathias Goebel's avatar
Mathias Goebel committed
958
                for $l in $labelAlt
Mathias Goebel's avatar
Mathias Goebel committed
959
                return
960
961
                    element xhtml:li {
                    attribute class {"label-" || string($l/@type)},
Mathias Goebel's avatar
Mathias Goebel committed
962
963
964
965
966
                    $l/text(),
                    if($l/@type = "variant")
                    then ()
                    else (
                        "&#160;",
967
968
                        element xhtml:a {
                            attribute href { string($l/@xml:base) || string($l) },
Mathias Goebel's avatar
Mathias Goebel committed
969
970
971
972
973
                            <xhtml:i title="Link zu externer Ressource" class="fa fa-external-link"></xhtml:i>
                        }
                    )
                },
                (: idno :)
974
                local:idno($idnos),
975
976
977
                (: creator :)
                if (not(exists($creator))) then () else
                local:creator($creator),
Mathias Goebel's avatar
Mathias Goebel committed
978
                (: note :)
979
                local:note($note),
Mathias Goebel's avatar
Mathias Goebel committed
980
                (: bibl :)
981
                local:bibl($bibl),
Mathias Goebel's avatar
Mathias Goebel committed
982
983
                (: events took place :)
                for $l in $tookPlaceAt
984
                let $id := $l/@target => substring-after(":") => substring-before(" ")
Mathias Goebel's avatar
Mathias Goebel committed
985
986
987
988
989
                return
                    element xhtml:li {
                        attribute class { "took-place-at" },
                        element xhtml:a {
                        attribute href { "?e=" || $id },
Mathias Goebel's avatar
Mathias Goebel committed
990
                        <xhtml:i class="fa fa-flag" aria-hidden="true"></xhtml:i>,
Mathias Goebel's avatar
Mathias Goebel committed
991
                        "&#160;",
Mathias Goebel's avatar
Mathias Goebel committed
992
                        $f-indexproc:dataCollection/id($id)/*[1]/string()
Mathias Goebel's avatar
Mathias Goebel committed
993
994
                        }
                    },
995
                (: former_or_current_location :)
996
                local:has-former-or-current-location($formerCurrentLocation),
Mathias Goebel's avatar
Mathias Goebel committed
997
                (: links :)
Mathias Goebel's avatar
Mathias Goebel committed
998
                local:links($links),
Mathias Goebel's avatar
Mathias Goebel committed
999
                local:li-code($place),
1000
                element xhtml:ul {
For faster browsing, not all history is shown. View entire blame