From 73341e02c50454f24e9512ffda58c8918b54718a Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Wed, 8 Jan 2025 11:45:45 +0100 Subject: [PATCH] update xqueries to use new functions --- add/data/xql/getEditionURI.xql | 8 ++++---- add/data/xqm/eutil.xqm | 4 ++-- add/index.xql | 33 ++++++++++++++++++++------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/add/data/xql/getEditionURI.xql b/add/data/xql/getEditionURI.xql index 47204d6d3..cf1d34334 100644 --- a/add/data/xql/getEditionURI.xql +++ b/add/data/xql/getEditionURI.xql @@ -12,6 +12,7 @@ xquery version "3.1"; (: IMPORTS ================================================================= :) import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/eutil" at "../xqm/eutil.xqm"; (: NAMESPACE DECLARATIONS ================================================== :) @@ -27,7 +28,6 @@ declare option output:method "text"; let $uri := request:get-parameter('uri', '') return - if (doc-available($uri)) then - ($uri) - else - (edition:findEdition($uri)) + if (edition:getEditionURI($uri)) + then edition:getEditionURI($uri) + else edition:findEditionUris()[1] diff --git a/add/data/xqm/eutil.xqm b/add/data/xqm/eutil.xqm index 4bb09a610..096b3cbf6 100644 --- a/add/data/xqm/eutil.xqm +++ b/add/data/xqm/eutil.xqm @@ -343,8 +343,8 @@ declare function eutil:getLanguage($edition as xs:string?) as xs:string { if (request:get-parameter("lang", "") != "") then request:get-parameter("lang", "") - else if(eutil:getPreference('application_language', edition:findEdition($edition))) then - eutil:getPreference('application_language', edition:findEdition($edition)) + else if(eutil:getPreference('application_language', edition:getEditionURI($edition))) then + eutil:getPreference('application_language', edition:getEditionURI($edition)) else 'de' }; diff --git a/add/index.xql b/add/index.xql index 71ec1e354..700a3e12e 100644 --- a/add/index.xql +++ b/add/index.xql @@ -21,11 +21,20 @@ declare option output:omit-xml-declaration "yes"; (: VARIABLE DECLARATIONS =================================================== :) declare variable $edition := request:get-parameter("edition", ""); -declare variable $editionUri := edition:findEdition($edition); -declare variable $additional_css_path := eutil:getPreference('additional_css_path', $editionUri); +declare variable $editionUri := edition:getEditionURI($edition); -let $eoEditionFiles := collection('/db/apps')//edirom:edition[@xml:id] -let $eoEditionFilesCount := count($eoEditionFiles) +(: if no valid $editionUri is provided by the request we have to check the whole database :) +let $eoEditionUris := + if($editionUri) + then $editionUri + else edition:findEditionUris() +let $eoEditionUrisCount := count($eoEditionUris) + +(: if we have only one valid $editionUri we can look for edition specific CSS :) +let $additional_css_path := + if($eoEditionUrisCount eq 1) + then eutil:getPreference('additional_css_path', $eoEditionUris) + else () let $comment := comment{" * Edirom Online @@ -74,7 +83,7 @@ let $eoIndexPage := { - if(($eoEditionFilesCount gt 1 or $eoEditionFilesCount eq 0) and not($edition)) then + if(($eoEditionUrisCount gt 1 or $eoEditionUrisCount eq 0) and not($edition)) then () else (, @@ -87,27 +96,25 @@ let $eoIndexPage := } - {if(($eoEditionFilesCount gt 1 or $eoEditionFilesCount eq 0) and not($edition)) then + {if(($eoEditionUrisCount gt 1 or $eoEditionUrisCount eq 0) and not($edition)) then (

Edirom Online

- {if($eoEditionFilesCount eq 0 and not($edition)) then + {if($eoEditionUrisCount eq 0 and not($edition)) then () else (,