Commit 76cc540a authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

get interwiki links

parent be877020
......@@ -225,7 +225,9 @@ declare function local:idno($idnos as element()*)
as element(xhtml:li)* {
for $idno in $idnos
let $str := string($idno)
let $wikipedia := if($idno/@type = "GND") then local:gnd-wikipedia($str) else ()
let $wikipedia :=
if($idno/@type = "GND") then local:gnd-wikipedia($str) else
if($idno/@type = "Wikidata") then local:wikidata-wikipedia($str) else ()
return
element xhtml:li {
attribute class {"idno"},
......@@ -286,6 +288,21 @@ return
string($response//foaf:page/@rdf:resource)
};
declare function local:wikidata-wikipedia($wikidata-id as xs:string)
as xs:string?{
let $query := escape-uri("SELECT ?s WHERE{?s schema:about wd:" || $wikidata-id || ".}", true())
let $url := "https://query.wikidata.org/sparql?query=" || $query
let $persist := false()
let $request-headers := ()
let $uris := httpclient:get(xs:anyURI($url), $persist, $request-headers)//*:uri/string()
return (
$uris[matches(., "de\.wikipedia")],
$uris[matches(., "en\.wikipedia")],
$uris[matches(., "fr\.wikipedia")],
$uris[matches(., "it\.wikipedia")],
$uris[1])[1]
};
(:~
: transformation from tei:note to xhtml:li
: :)
......
Markdown is supported
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