Commit 00357837 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

add ADB and NDB links based on beacon files

parent 21b72fe7
......@@ -30,6 +30,10 @@ declare variable $f-indexproc:getNotebook := $f-indexproc:targetStart || $f-inde
declare variable $f-indexproc:dataPath := '/db/sade-projects/textgrid/data/xml/data/';
declare variable $f-indexproc:dataCollection := collection($f-indexproc:dataPath);
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"))
));
(:~
: Helper function to collect all main nodes from the index files.
:)
......@@ -227,7 +231,25 @@ return
element xhtml:a {
attribute href { string($idno/@xml:base) || $str },
<xhtml:i title="Link zu externer Ressource" class="fa fa-external-link"></xhtml:i>
}
},
(: 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"
else "ŃDB-Eintrag basierend auf GND"
},
attribute href {$url},
if(ends-with($url, "adbcontent"))
then "ADB"
else "NDB"
})
else ()
}
};
......@@ -1013,3 +1035,22 @@ else
}
}
};
declare function local:beacon-parser($url as xs:anyURI)
as map(*) {
let
$persist := false(),
$request-headers := (),
$beacon := httpclient:get($url, $persist, $request-headers)//httpclient:body/node()
=> xmldb:decode() => tokenize("&#x0A;")
let $target := $beacon[starts-with(., "#TARGET")] => substring-after(": ")
(: should return something like "http://www.deutsche-biographie.de/pnd{ID}.html#adbcontent"
: where «{ID}» is to be replaced by the GND ID :)
let $replacement := "\{ID\}"
return map:new(
for $i in $beacon[not(starts-with(., "#"))][. != ""]
return
map:entry($i, replace($target, $replacement, $i))
)
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment