Skip to content

Commit

Permalink
moved core:order-by-cert() to the shared module
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Oct 23, 2017
1 parent 52f001d commit ab09294
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
5 changes: 3 additions & 2 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import module namespace str="http://xquery.weber-gesamtausgabe.de/modules/str" a
import module namespace app-shared="http://xquery.weber-gesamtausgabe.de/modules/app-shared" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/app-shared.xqm";
import module namespace date="http://xquery.weber-gesamtausgabe.de/modules/date" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/date.xqm";
import module namespace cache="http://xquery.weber-gesamtausgabe.de/modules/cache" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/cache.xqm";
import module namespace wega-util-shared="http://xquery.weber-gesamtausgabe.de/modules/wega-util-shared" at "xmldb:exist:///db/apps/WeGA-WebApp-lib/xquery/wega-util-shared.xqm";

(:
: ****************************
Expand Down Expand Up @@ -848,7 +849,7 @@ declare
case 'death' return $model('doc')//tei:placeName[parent::tei:death]
default return ()
return
for $placeName at $count in core:order-by-cert($placeNames)
for $placeName at $count in wega-util-shared:order-by-cert($placeNames)
let $preposition :=
if(matches(normalize-space($placeName), '^(auf|bei)')) then ' ' (: Präposition 'in' weglassen wenn schon eine andere vorhanden :)
else concat(' ', lower-case(lang:get-language-string('in', $model('lang'))), ' ')
Expand All @@ -869,7 +870,7 @@ declare
case 'death' return $model('doc')//tei:death/tei:date[not(@type)]
case 'funeral' return $model('doc')//tei:death/tei:date[@type = 'funeral']
default return ()
let $orderedDates := core:order-by-cert($dates)
let $orderedDates := wega-util-shared:order-by-cert($dates)
let $julian-tooltip := function($date as xs:date, $lang as xs:string) as element(sup) {
<sup class="jul"
data-toggle="tooltip"
Expand Down
19 changes: 0 additions & 19 deletions modules/core.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,3 @@ declare function core:link-to-current-app($relLink as xs:string?, $exist-vars as
declare function core:permalink($docID as xs:string) as xs:anyURI? {
xs:anyURI(config:get-option('permaLinkPrefix') || core:link-to-current-app($docID))
};

(:~
: Sort items by their cert-attribute
: Primarily used for sorting birth and death dates
~:)
declare function core:order-by-cert($items as item()*) as item()* {
let $order := map {
'high' := 1,
'medium' := 2,
'low' := 3,
'unknown' := 4,
'' := 0
}
return
for $i in $items
let $cert := $i/string(@cert)
order by $order($cert)
return $i
};

0 comments on commit ab09294

Please sign in to comment.