-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
94 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
xquery version "3.1" encoding "UTF-8"; | ||
|
||
(:~ | ||
: | ||
: Module for exporting BEACON files | ||
: see https://de.wikipedia.org/wiki/Wikipedia:BEACON | ||
: | ||
:) | ||
|
||
declare namespace tei="http://www.tei-c.org/ns/1.0"; | ||
declare namespace mei="http://www.music-encoding.org/ns/mei"; | ||
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; | ||
declare namespace beacon="https://de.wikipedia.org/wiki/Wikipedia:BEACON"; | ||
declare namespace request="http://exist-db.org/xquery/request"; | ||
declare namespace response="http://exist-db.org/xquery/response"; | ||
|
||
import module namespace core="http://xquery.weber-gesamtausgabe.de/modules/core" at "core.xqm"; | ||
import module namespace config="http://xquery.weber-gesamtausgabe.de/modules/config" at "config.xqm"; | ||
import module namespace wega-util="http://xquery.weber-gesamtausgabe.de/modules/wega-util" at "wega-util.xqm"; | ||
import module namespace str="http://xquery.weber-gesamtausgabe.de/modules/str" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/str.xqm"; | ||
import module namespace mycache="http://xquery.weber-gesamtausgabe.de/modules/cache" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/cache.xqm"; | ||
|
||
declare option output:method "text"; | ||
declare option output:media-type "text/plain"; | ||
|
||
|
||
declare function beacon:new($type as xs:string) as xs:string { | ||
let $gnd-ids := | ||
switch($type) | ||
case 'pnd' return core:data-collection('persons')//tei:idno[@type='gnd'] | ||
case 'gkd' return core:data-collection('orgs')//tei:idno[@type='gnd'] | ||
case 'works' return core:data-collection('works')//mei:altId[@type='gnd'] | ||
default return () | ||
let $desc := | ||
switch($type) | ||
case 'pnd' return '#DESCRIPTION: Personendatensätze der Carl-Maria-von-Weber-Gesamtausgabe' | ||
case 'gkd' return '#DESCRIPTION: Datensätze Organisationen/Körperschaften der Carl-Maria-von-Weber-Gesamtausgabe' | ||
case 'works' return '#DESCRIPTION: Werkdatensätze der Carl-Maria-von-Weber-Gesamtausgabe' | ||
default return () | ||
let $feed := | ||
switch($type) | ||
case 'pnd' return '#FEED: http://weber-gesamtausgabe.de/pnd_beacon.txt' | ||
case 'gkd' return '#FEED: http://weber-gesamtausgabe.de/gkd_beacon.txt' | ||
case 'works' return '#FEED: http://weber-gesamtausgabe.de/works_beacon.txt' | ||
default return () | ||
let $header := ( | ||
'#FORMAT: BEACON', | ||
'#PREFIX: http://d-nb.info/gnd/', | ||
'#VERSION: 0.1', | ||
'#TARGET: https://weber-gesamtausgabe.de/de/gnd/{ID}', | ||
$feed, | ||
'#CONTACT: Peter Stadler <stadler [ at ] weber-gesamtausgabe.de>', | ||
'#INSTITUTION: Carl-Maria-von-Weber-Gesamtausgabe (WeGA)', | ||
$desc, | ||
concat('#TIMESTAMP: ', current-dateTime()) | ||
) | ||
return concat( | ||
string-join($header, ' '), | ||
' ', | ||
string-join($gnd-ids, ' ') | ||
) | ||
}; | ||
|
||
declare function beacon:beacon($type as xs:string) as xs:string { | ||
let $fileName := | ||
switch($type) | ||
case 'pnd' return 'pnd_beacon.txt' | ||
case 'gkd' return 'gkd_beacon.txt' | ||
case 'works' return 'works_beacon.txt' | ||
default return () | ||
let $onFailureFunc := function($errCode, $errDesc) { | ||
core:logToFile('warn', string-join(($errCode, $errDesc), ' ;; ')) | ||
} | ||
return | ||
util:binary-to-string( | ||
mycache:doc( | ||
str:join-path-elements(($config:tmp-collection-path, $fileName)), | ||
beacon:new#1, $type, | ||
function($currentDateTimeOfFile as xs:dateTime?) as xs:boolean { wega-util:check-if-update-necessary($currentDateTimeOfFile, ()) }, | ||
$onFailureFunc | ||
) | ||
) | ||
}; | ||
|
||
let $beacon := request:get-attribute('beacon') | ||
let $setHeader := response:set-header('Access-Control-Allow-Origin', '*') | ||
return | ||
beacon:beacon($beacon) |
This file was deleted.
Oops, something went wrong.