From 8efd7e02ed22171f56f29c99d6c802642b9bb9b6 Mon Sep 17 00:00:00 2001 From: Dennis Friedl Date: Wed, 31 May 2023 16:38:50 +0200 Subject: [PATCH 001/103] Update search.xql * an Contributing Guidelines angepasst --- add/data/xql/search.xql | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/add/data/xql/search.xql b/add/data/xql/search.xql index 6f2fb4a2b..1d360134e 100644 --- a/add/data/xql/search.xql +++ b/add/data/xql/search.xql @@ -1,31 +1,21 @@ -xquery version "3.0"; +xquery version "3.1"; (: - Edirom Online - Copyright (C) 2011 The Edirom Project - http://www.edirom.de - - Edirom Online is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Edirom Online is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Edirom Online. If not, see . +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) -import module namespace kwic="http://exist-db.org/xquery/kwic"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; declare namespace tei="http://www.tei-c.org/ns/1.0"; declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace request="http://exist-db.org/xquery/request"; +declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; + +import module namespace kwic="http://exist-db.org/xquery/kwic"; +import module namespace request="http://exist-db.org/xquery/request"; +import module namespace transform="http://exist-db.org/xquery/transform"; + +import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -(:declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";:) +declare option output:method "xhtml"; +declare option output:media-type "text/html"; declare variable $lang := request:get-parameter('lang', ''); From 9251f51c7863fcecd093f59afc3ce2c5e44407a9 Mon Sep 17 00:00:00 2001 From: Dennis Friedl Date: Wed, 31 May 2023 17:13:40 +0200 Subject: [PATCH 002/103] Update getZone.xql * Adjusted to the Contributing Guidelines --- add/data/xql/getZone.xql | 44 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/add/data/xql/getZone.xql b/add/data/xql/getZone.xql index 738b17430..bf75f0fbb 100644 --- a/add/data/xql/getZone.xql +++ b/add/data/xql/getZone.xql @@ -1,21 +1,6 @@ -xquery version "1.0"; +xquery version "3.1"; (: - Edirom Online - Copyright (C) 2011 The Edirom Project - http://www.edirom.de - - Edirom Online is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Edirom Online is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Edirom Online. If not, see . +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. :) (:~ @@ -24,14 +9,15 @@ xquery version "1.0"; @author Daniel Röwenstrunk :) -declare namespace request="http://exist-db.org/xquery/request"; declare namespace mei="http://www.music-encoding.org/ns/mei"; declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; - -declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; +import module namespace request = "http://exist-db.org/xquery/request"; +import module namespace xmldb = "http://exist-db.org/xquery/xmldb"; +declare option output:method "json"; +declare option output:media-type "application/json"; let $uri := request:get-parameter('uri', '') let $zoneId := request:get-parameter('zoneId', '') @@ -40,12 +26,12 @@ let $mei := doc($uri)/root() let $zone := $mei/id($zoneId) return ( - concat('{', - 'zoneId: "', $zone/string(@xml:id), '", ', - 'pageId: "', $zone/../string(@xml:id), '", ', - 'ulx: "', $zone/string(@ulx), '", ', - 'uly: "', $zone/string(@uly), '", ', - 'lrx: "', $zone/string(@lrx), '", ', - 'lry: "', $zone/string(@lry), '"', - '}') + map { + 'zoneId': $zone/string(@xml:id), + 'pageId': $zone/../string(@xml:id), + 'ulx': $zone/string(@ulx), + 'uly': $zone/string(@uly), + 'lrx': $zone/string(@lrx), + 'lry': $zone/string(@lry) + } ) \ No newline at end of file From e15cfbea9142b38d9c0e510d6dd9e6a943ec9683 Mon Sep 17 00:00:00 2001 From: Dennis Friedl Date: Wed, 31 May 2023 17:25:00 +0200 Subject: [PATCH 003/103] Update getXml.xql Adjusted to the Contributing Guidelines --- add/data/xql/getXml.xql | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/add/data/xql/getXml.xql b/add/data/xql/getXml.xql index ade41e67d..74ebc9816 100644 --- a/add/data/xql/getXml.xql +++ b/add/data/xql/getXml.xql @@ -1,31 +1,20 @@ -xquery version "1.0"; +xquery version "3.1"; (: - Edirom Online - Copyright (C) 2011 The Edirom Project - http://www.edirom.de - - Edirom Online is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +For LICENSE-Details please refer to the LICENSE file in the root directory of this repository. +:) - Edirom Online is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with Edirom Online. If not, see . +declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; - ID: $Id: getXml.xql 1219 2012-01-20 08:33:28Z daniel $ -:) +import module namespace request = "http://exist-db.org/xquery/request"; import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; - -declare option exist:serialize "method=xml media-type=text/xml omit-xml-declaration=no indent=yes"; +declare option output:method "xml"; +declare option output:media-type "text/xml"; +declare option output:omit-xml-declaration "no"; +declare option output:indent "yes"; let $uri := request:get-parameter('uri', '') let $internalId := request:get-parameter('internalId', '') From 3adb97abd9d098ccdeb33d4b73ce9445d869ba03 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 8 Nov 2023 15:56:15 +0100 Subject: [PATCH 004/103] fix syntax: getReducedDocument.xql * add missing parenthesis --- add/data/xql/getReducedDocument.xql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add/data/xql/getReducedDocument.xql b/add/data/xql/getReducedDocument.xql index 68b83029f..4cb5c1d5c 100644 --- a/add/data/xql/getReducedDocument.xql +++ b/add/data/xql/getReducedDocument.xql @@ -59,5 +59,5 @@ let $xsl := if($xslInstruction)then(doc($xslInstruction))else('../xslt/teiBody2H let $params := (,) return - if($xslInstruction)then(transform:transform($doc/root(), $xsl, {$params}) + if($xslInstruction)then(transform:transform($doc/root(), $xsl, {$params})) else(transform:transform($doc/root(), $xsl, {$params})) From 2ba2451ebec61f767e73fac201eec4034ef8c067 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 8 Nov 2023 16:03:17 +0100 Subject: [PATCH 005/103] fix position of variable declarations --- add/data/xql/getReducedDocument.xql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/add/data/xql/getReducedDocument.xql b/add/data/xql/getReducedDocument.xql index 4cb5c1d5c..19ba9e68a 100644 --- a/add/data/xql/getReducedDocument.xql +++ b/add/data/xql/getReducedDocument.xql @@ -28,6 +28,12 @@ declare namespace request="http://exist-db.org/xquery/request"; declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; (:declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";:) +declare variable $edition := request:get-parameter('edition', ''); +declare variable $imageserver := eutil:getPreference('image_server', $edition); +declare variable $imagePrefix := if($imageserver = 'leaflet') + then(eutil:getPreference('leaflet_prefix', $edition)) + else(eutil:getPreference('image_prefix', $edition)); + let $uri := request:get-parameter('uri', '') let $selectionId := request:get-parameter('selectionId', '') let $subtreeRoot := request:get-parameter('subtreeRoot', '') @@ -47,12 +53,6 @@ let $xslInstruction := for $i in serialize($xslInstruction, ()) then(substring-before(substring-after($i, 'href="'), '"')) else() -declare variable $edition := request:get-parameter('edition', ''); -declare variable $imageserver := eutil:getPreference('image_server', $edition); -declare variable $imagePrefix := if($imageserver = 'leaflet') - then(eutil:getPreference('leaflet_prefix', $edition)) - else(eutil:getPreference('image_prefix', $edition)); - (:let $imagePrefix := eutil:getPreference('image_prefix', request:get-parameter('edition', '')):) let $xsl := if($xslInstruction)then(doc($xslInstruction))else('../xslt/teiBody2HTML.xsl') From 000492468dace9d98152490ef3185de3e8f5c31c Mon Sep 17 00:00:00 2001 From: bwbohl Date: Wed, 8 Nov 2023 16:03:57 +0100 Subject: [PATCH 006/103] format and indent xql-files --- add/data/xql/checkTextGridLogin.xql | 6 +- add/data/xql/edirom_printPreview.xql | 183 ++-- add/data/xql/getAnnotation.xql | 458 ++++++---- add/data/xql/getAnnotationInfos.xql | 66 +- add/data/xql/getAnnotationMeta.xql | 102 ++- add/data/xql/getAnnotationOpenAllUris.xql | 85 +- add/data/xql/getAnnotationParticipants.xql | 13 +- add/data/xql/getAnnotationPreviews.xql | 74 +- add/data/xql/getAnnotationText.xql | 20 +- add/data/xql/getAnnotations.xql | 38 +- add/data/xql/getAnnotationsInRendering.xql | 47 +- add/data/xql/getAnnotationsInText.xql | 58 +- add/data/xql/getAnnotationsOnPage.xql | 150 ++-- add/data/xql/getAudioPlayer.xql | 539 +++++++----- add/data/xql/getChapters.xql | 179 ++-- add/data/xql/getConcordances.xql | 79 +- add/data/xql/getEdition.xql | 5 +- add/data/xql/getEditionURI.xql | 10 +- add/data/xql/getExtendedStaff.xql | 112 ++- add/data/xql/getHeader.xql | 61 +- add/data/xql/getHelp.xql | 20 +- add/data/xql/getInternalIdType.xql | 74 +- add/data/xql/getLanguageFile.xql | 37 +- add/data/xql/getMeasure.xql | 36 +- add/data/xql/getMeasurePage.xql | 74 +- add/data/xql/getMeasures.xql | 151 ++-- add/data/xql/getMeasuresOnPage.xql | 46 +- add/data/xql/getMovements.xql | 33 +- add/data/xql/getMovementsFirstPage.xql | 21 +- add/data/xql/getMusicInMdiv.xql | 23 +- add/data/xql/getNavigatorConfig.xql | 151 ++-- add/data/xql/getOverlayOnPage.xql | 25 +- add/data/xql/getOverlays.xql | 33 +- add/data/xql/getPages.xql | 77 +- add/data/xql/getParts.xql | 29 +- add/data/xql/getPreferences.xql | 35 +- add/data/xql/getReducedDocument.xql | 56 +- add/data/xql/getRendering.xql | 52 +- add/data/xql/getSummary.xql | 967 ++++++++++++--------- add/data/xql/getText.xql | 134 ++- add/data/xql/getWorkID.xql | 12 +- add/data/xql/getWorks.xql | 19 +- add/data/xql/getXml.xql | 14 +- add/data/xql/getZone.xql | 25 +- add/data/xql/getiFrameURL.xql | 13 +- add/data/xql/loginToTextGrid.xql | 20 +- add/data/xql/search.xql | 267 ++++-- 47 files changed, 2837 insertions(+), 1892 deletions(-) diff --git a/add/data/xql/checkTextGridLogin.xql b/add/data/xql/checkTextGridLogin.xql index 3d154e3f5..8a0ce0a00 100644 --- a/add/data/xql/checkTextGridLogin.xql +++ b/add/data/xql/checkTextGridLogin.xql @@ -1,12 +1,12 @@ xquery version "3.0"; -declare namespace html="http://www.w3.org/1999/xhtml"; -declare namespace h="http://exist-db.org/xquery/httpclient"; +declare namespace html = "http://www.w3.org/1999/xhtml"; +declare namespace h = "http://exist-db.org/xquery/httpclient"; let $sessionId := request:get-parameter('sessionId', '') let $test := httpclient:head(xs:anyURI('http://textgridlab.org/1.0/tgcrud/rest/textgrid:208dw/data?sessionId=' || $sessionId), - false(), ()) +false(), ()) let $status := $test/root()/httpclient:response/string(@statusCode) let $status := response:set-status-code(xs:int($status)) diff --git a/add/data/xql/edirom_printPreview.xql b/add/data/xql/edirom_printPreview.xql index 6762ed4c7..fa91cd391 100644 --- a/add/data/xql/edirom_printPreview.xql +++ b/add/data/xql/edirom_printPreview.xql @@ -1,14 +1,14 @@ xquery version "1.0"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace xslfo="http://exist-db.org/xquery/xslfo"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace xslfo = "http://exist-db.org/xquery/xslfo"; -declare namespace fo="http://www.w3.org/1999/XSL/Format"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace tei="http://www.tei-c.org/ns/1.0"; +declare namespace fo = "http://www.w3.org/1999/XSL/Format"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare namespace eof = "http://www.edirom.de/xquery/ediromOnlineFunctions"; declare namespace xhtml = "http://www.w3.org/1999/xhtml"; @@ -17,98 +17,143 @@ declare option exist:serialize "method=html media-type=text/html omit-xml-declar (: VARIABLES ========================================================= :) declare variable $lang := 'en'; -declare variable $base := concat('file:', replace(system:get-module-load-path(),'\\','/'), '/../xslt/'); +declare variable $base := concat('file:', replace(system:get-module-load-path(), '\\', '/'), '/../xslt/'); declare variable $edition := request:get-parameter('edition', ''); -declare variable $imageserver := eutil:getPreference('image_server', $edition); -declare variable $facsBasePath := if($imageserver = 'leaflet') - then(eutil:getPreference('leaflet_prefix', $edition)) - else(eutil:getPreference('image_prefix', $edition)); +declare variable $imageserver := eutil:getPreference('image_server', $edition); +declare variable $facsBasePath := if ($imageserver = 'leaflet') +then + (eutil:getPreference('leaflet_prefix', $edition)) +else + (eutil:getPreference('image_prefix', $edition)); (:declare variable $facsBasePath := eutil:getPreference('image_prefix', request:get-parameter('edition', ''));:) declare variable $printResolution := 150; -declare variable $facsAreaWidth := 6.5;(: in inch :) +declare variable $facsAreaWidth := 6.5; (: in inch :) declare variable $facsMetaHeight := 30; -declare variable $uri := request:get-parameter('uri',''); -declare variable $type := request:get-parameter('type',''); +declare variable $uri := request:get-parameter('uri', ''); +declare variable $type := request:get-parameter('type', ''); declare variable $doc := doc($uri)/root(); -declare variable $langFile := if(doc-available(concat($base, '../xslt/i18n/', $lang, '.xml'))) - then(doc(concat($base, '../xslt/i18n/', $lang, '.xml'))) - else(concat($base, '../xslt/i18n/', $lang, '.xml')); - -declare variable $facsItems := $doc//mei:surface/mei:graphic[@type='facsimile']; -declare variable $pageFormat := if($doc//mei:facsimile or $doc//tei:facsimile) - then if((sum(for $h in $facsItems/@height return $h) div count($facsItems)) gt (sum(for $h in $facsItems/@width return $h) div count($facsItems))) - then 'A4' - else 'A4ls' - else(); - -declare variable $pageMaster := doc(concat($base,'edirom_fo_layoutMasterSet.xml'))//fo:*[@master-name = $pageFormat]; +declare variable $langFile := if (doc-available(concat($base, '../xslt/i18n/', $lang, '.xml'))) +then + (doc(concat($base, '../xslt/i18n/', $lang, '.xml'))) +else + (concat($base, '../xslt/i18n/', $lang, '.xml')); + +declare variable $facsItems := $doc//mei:surface/mei:graphic[@type = 'facsimile']; +declare variable $pageFormat := if ($doc//mei:facsimile or $doc//tei:facsimile) +then + if ((sum(for $h in $facsItems/@height + return + $h) div count($facsItems)) gt (sum(for $h in $facsItems/@width + return + $h) div count($facsItems))) + then + 'A4' + else + 'A4ls' +else + (); + +declare variable $pageMaster := doc(concat($base, 'edirom_fo_layoutMasterSet.xml'))//fo:*[@master-name = $pageFormat]; declare variable $ediromOnlineRoot := request:get-context-path(); (: FUNCTIONS ========================================================= :) -declare function eof:getLabel($key as xs:string){ - if($langFile/id($key) and not($langFile/id($key)/text() eq '')) - then($langFile/id($key)/text()) - else($key) +declare function eof:getLabel($key as xs:string) { + if ($langFile/id($key) and not($langFile/id($key)/text() eq '')) + then + ($langFile/id($key)/text()) + else + ($key) }; -declare function eof:getFacsImgParas($areaWidth){ - concat('&dw=',floor($printResolution*$areaWidth), '&mo=scale') +declare function eof:getFacsImgParas($areaWidth) { + concat('&dw=', floor($printResolution * $areaWidth), '&mo=scale') }; -declare function eof:getPageRegionBodyWidth(){ - if($pageMaster/fo:region-body/@margin) - then(concat(number(substring-before($pageMaster/@page-width, 'mm')) - -number(substring-before($pageMaster/fo:region-body/@margin, 'mm'))*2, 'mm')) - else(concat(number(substring-before($pageMaster/@page-width, 'mm')) - -sum(for $a in $pageMaster/fo:region-body/@margin-left | $pageMaster/fo:region-body/@margin-right - return number(substring-before($a, 'mm'))),'mm')) +declare function eof:getPageRegionBodyWidth() { + if ($pageMaster/fo:region-body/@margin) + then + (concat(number(substring-before($pageMaster/@page-width, 'mm')) + - number(substring-before($pageMaster/fo:region-body/@margin, 'mm')) * 2, 'mm')) + else + (concat(number(substring-before($pageMaster/@page-width, 'mm')) + - sum(for $a in $pageMaster/fo:region-body/@margin-left | $pageMaster/fo:region-body/@margin-right + return + number(substring-before($a, 'mm'))), 'mm')) }; -declare function eof:getPageRegionBodyHeight(){ - if($pageMaster/fo:region-body/@margin) - then(concat(number(substring-before($pageMaster/@page-height, 'mm')) - -number(substring-before($pageMaster/fo:region-body/@margin, 'mm'))*2, 'mm')) - else(concat(number(substring-before($pageMaster/@page-height, 'mm')) - -sum(for $a in $pageMaster/fo:region-body/@margin-top | $pageMaster/fo:region-body/@margin-bottom - return number(substring-before($a, 'mm'))) - -$facsMetaHeight,'mm')) +declare function eof:getPageRegionBodyHeight() { + if ($pageMaster/fo:region-body/@margin) + then + (concat(number(substring-before($pageMaster/@page-height, 'mm')) + - number(substring-before($pageMaster/fo:region-body/@margin, 'mm')) * 2, 'mm')) + else + (concat(number(substring-before($pageMaster/@page-height, 'mm')) + - sum(for $a in $pageMaster/fo:region-body/@margin-top | $pageMaster/fo:region-body/@margin-bottom + return + number(substring-before($a, 'mm'))) + - $facsMetaHeight, 'mm')) }; -declare function eof:insertAttributeSet_h1(){ +declare function eof:insertAttributeSet_h1() { attribute font-weight {'bold'} }; (: OUTPUT ========================================================= :) -let $xsl_source := concat($base,'edirom_source2Print.xsl') -let $xsl_text := concat($base,'edirom_text2Print.xsl') -let $paras := - - - - - - - - - +let $xsl_source := concat($base, 'edirom_source2Print.xsl') +let $xsl_text := concat($base, 'edirom_text2Print.xsl') +let $paras := + + + + + + + + + let $width := eof:getPageRegionBodyWidth() let $height := eof:getPageRegionBodyHeight() let $type := request:get-parameter('type', '') -let $docUri := if(contains($uri, '#')) then(substring-before($uri, '#')) else($uri) +let $docUri := if (contains($uri, '#')) then + (substring-before($uri, '#')) +else + ($uri) let $doc := doc($docUri) return - if($type = 'work') - then('work') - else if($type = 'source') - then transform:transform($doc, $xsl_source, $paras) - else if($type = 'text') - then transform:transform($doc, $xsl_text, $paras) - else('last else') + if ($type = 'work') + then + ('work') + else + if ($type = 'source') + then + transform:transform($doc, $xsl_source, $paras) + else + if ($type = 'text') + then + transform:transform($doc, $xsl_text, $paras) + else + ('last else') diff --git a/add/data/xql/getAnnotation.xql b/add/data/xql/getAnnotation.xql index 993fb6b5b..c43af1b4d 100644 --- a/add/data/xql/getAnnotation.xql +++ b/add/data/xql/getAnnotation.xql @@ -26,16 +26,16 @@ xquery version "3.1"; @author Daniel Röwenstrunk :) -import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; -import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; +import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; +import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace exist="http://exist.sourceforge.net/NS/exist"; -declare namespace edirom_image="http://www.edirom.de/ns/image"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace exist = "http://exist.sourceforge.net/NS/exist"; +declare namespace edirom_image = "http://www.edirom.de/ns/image"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "xhtml"; @@ -43,10 +43,12 @@ declare option output:media-type "text/html"; declare variable $imageWidth := 600; declare variable $edition := request:get-parameter('edition', ''); -declare variable $imageserver := eutil:getPreference('image_server', $edition); -declare variable $imageBasePath := if($imageserver = 'leaflet') - then(eutil:getPreference('leaflet_prefix', $edition)) - else(eutil:getPreference('image_prefix', $edition)); +declare variable $imageserver := eutil:getPreference('image_server', $edition); +declare variable $imageBasePath := if ($imageserver = 'leaflet') +then + (eutil:getPreference('leaflet_prefix', $edition)) +else + (eutil:getPreference('image_prefix', $edition)); declare variable $lang := request:get-parameter('lang', ''); @@ -59,14 +61,17 @@ declare variable $lang := request:get-parameter('lang', ''); @return The zone element :) declare function local:getZone($elem as element()) as element()? { - if($elem/@facs) - then( + if ($elem/@facs) + then + ( let $zoneId := replace($elem/@facs, '^#', '') - return $elem/root()/id($zoneId) - ) - else( + return + $elem/root()/id($zoneId) + ) + else + ( $elem - ) + ) }; (:~ @@ -79,21 +84,25 @@ declare function local:getZone($elem as element()) as element()? { declare function local:getPriority($annot as node()) { let $uri := $annot/mei:ptr[@type eq 'priority']/string(@target) - let $doc := if(starts-with($uri,'#')) - then( - $annot/root() - ) - else( - doc(substring-before($uri,'#')) - ) - let $locID := substring-after($uri,'#') + let $doc := if (starts-with($uri, '#')) + then + ( + $annot/root() + ) + else + ( + doc(substring-before($uri, '#')) + ) + let $locID := substring-after($uri, '#') let $elem := $doc/id($locID) return - if($elem/mei:name) - then(normalize-space(eutil:getLocalizedName($elem, $lang))) - else($locID) + if ($elem/mei:name) + then + (normalize-space(eutil:getLocalizedName($elem, $lang))) + else + ($locID) }; (:~ @@ -105,23 +114,28 @@ declare function local:getPriority($annot as node()) { :) declare function local:getCategories($annot as node()) { - let $uris := tokenize($annot/mei:ptr[@type eq 'categories']/string(@target),' ') - - let $string := for $uri in $uris - let $doc := if(starts-with($uri,'#')) - then( - $annot/root() - ) - else( - doc(substring-before($uri,'#')) - ) - let $locID := substring-after($uri,'#') - let $elem := $doc/id($locID) - return - if($elem/mei:name) - then(eutil:getLocalizedName($elem, $lang)) - else($locID) - return $string + let $uris := tokenize($annot/mei:ptr[@type eq 'categories']/string(@target), ' ') + + let $string := for $uri in $uris + let $doc := if (starts-with($uri, '#')) + then + ( + $annot/root() + ) + else + ( + doc(substring-before($uri, '#')) + ) + let $locID := substring-after($uri, '#') + let $elem := $doc/id($locID) + return + if ($elem/mei:name) + then + (eutil:getLocalizedName($elem, $lang)) + else + ($locID) + return + $string }; @@ -177,12 +191,14 @@ declare function local:getImageAreaPathForTips($basePath as xs:string, $zone as let $cut_path := substring-before($imagePath, '.') - let $im_path := if($imageserver = 'digilib') - then(concat($basePath, $imagePath, '?dw=', $width, '&dh=', $height, '&wx=', $wx, '&wy=', $wy, '&ww=', $ww, '&wh=', $wh, '&mo=fit')) - else( - concat($basePath, $cut_path, '/0-0-0.jpg')) + let $im_path := if ($imageserver = 'digilib') + then + (concat($basePath, $imagePath, '?dw=', $width, '&dh=', $height, '&wx=', $wx, '&wy=', $wy, '&ww=', $ww, '&wh=', $wh, '&mo=fit')) + else + ( + concat($basePath, $cut_path, '/0-0-0.jpg')) return - $im_path + $im_path }; @@ -196,26 +212,44 @@ declare function local:getImageAreaPathForTips($basePath as xs:string, $zone as @return Returns $i if it's square is higher or equals $num. :) declare function local:getLowestSquareBase($i as xs:integer, $num as xs:integer) { - if($i*$i lt $num) - then(local:getLowestSquareBase($i+1,$num)) - else($i) + if ($i * $i lt $num) + then + (local:getLowestSquareBase($i + 1, $num)) + else + ($i) }; declare function local:getItemLabel($elem as element()) { let $name := local-name($elem) - return ( - if($name = 'measure') - then(if ($lang = 'de') then (concat('Takt ',$elem/@n)) else (concat('Bar ',$elem/@n))) - else(), + return + ( + if ($name = 'measure') + then + (if ($lang = 'de') then + (concat('Takt ', $elem/@n)) + else + (concat('Bar ', $elem/@n))) + else + (), - if($name = 'staff') - then(if ($lang = 'de') then (concat($elem/preceding::mei:staffDef[@n = $elem/@n][1]/@label.abbr,', Takt ',$elem/ancestor::mei:measure/@n)) else(concat($elem/preceding::mei:staffDef[@n = $elem/@n][1]/@label.abbr,', Bar ',$elem/ancestor::mei:measure/@n))) - else(), + if ($name = 'staff') + then + (if ($lang = 'de') then + (concat($elem/preceding::mei:staffDef[@n = $elem/@n][1]/@label.abbr, ', Takt ', $elem/ancestor::mei:measure/@n)) + else + (concat($elem/preceding::mei:staffDef[@n = $elem/@n][1]/@label.abbr, ', Bar ', $elem/ancestor::mei:measure/@n))) + else + (), - if($name = 'zone') - then(if ($lang = 'de') then (concat('Ausschnitt (S. ',$elem/parent::mei:surface/@n,')')) else (concat('Detail (p. ',$elem/parent::mei:surface/@n,')'))) - else() - ) + if ($name = 'zone') + then + (if ($lang = 'de') then + (concat('Ausschnitt (S. ', $elem/parent::mei:surface/@n, ')')) + else + (concat('Detail (p. ', $elem/parent::mei:surface/@n, ')'))) + else + () + ) }; @@ -228,60 +262,90 @@ declare function local:calculatePreviewsForTip($participants as xs:string*) { let $areaWidth := 204 let $areaHeight := 254 - let $elems := for $pUri in $participants - return doc(substring-before($pUri, '#'))/id(substring-after($pUri, '#')) + let $elems := for $pUri in $participants + return + doc(substring-before($pUri, '#'))/id(substring-after($pUri, '#')) let $zones := for $elem in $elems - return local:getZone($elem) - - let $tall := some $zone in $zones satisfies (number($zone/@lry) - number($zone/@uly) gt 2*(number($zone/@lrx) - number($zone/@ulx))) - let $wide := some $zone in $zones satisfies (2*(number($zone/@lry) - number($zone/@uly)) lt number($zone/@lrx) - number($zone/@ulx)) - - let $w := if($tall and not($wide)) - then(round(10000 div count($zones)) div 100) - else( - if($wide and not($tall)) - then(100) - else(round(10000 div local:getLowestSquareBase(1,count($zones))) div 100) - ) - - let $h := if($tall and not($wide)) - then(100) - else( - if($wide and not($tall)) - then(round(10000 div count($zones)) div 100) - else(round(10000 div local:getLowestSquareBase(1,count($zones))) div 100) - ) + return + local:getZone($elem) + + let $tall := some $zone in $zones + satisfies (number($zone/@lry) - number($zone/@uly) gt 2 * (number($zone/@lrx) - number($zone/@ulx))) + let $wide := some $zone in $zones + satisfies (2 * (number($zone/@lry) - number($zone/@uly)) lt number($zone/@lrx) - number($zone/@ulx)) + + let $w := if ($tall and not($wide)) + then + (round(10000 div count($zones)) div 100) + else + ( + if ($wide and not($tall)) + then + (100) + else + (round(10000 div local:getLowestSquareBase(1, count($zones))) div 100) + ) + + let $h := if ($tall and not($wide)) + then + (100) + else + ( + if ($wide and not($tall)) + then + (round(10000 div count($zones)) div 100) + else + (round(10000 div local:getLowestSquareBase(1, count($zones))) div 100) + ) let $width := floor($areaWidth * $w div 100) let $height := floor($areaHeight * $h div 100) for $zone in $zones - let $e := $elems[substring(@facs,2) = $zone/@xml:id][1] - let $e := if($e)then($e)else($zone) - - let $test := if($imageserver = 'digilib') - then( -
-
- + let $e := $elems[substring(@facs, 2) = $zone/@xml:id][1] + let $e := if ($e) then + ($e) + else + ($zone) + + let $test := if ($imageserver = 'digilib') + then + ( +
+
+
-
{local:getItemLabel($e)}
+
{local:getItemLabel($e)}
- ) - else( -
-
- + ) + else + ( +
+
+
-
{local:getItemLabel($e)}
+
{local:getItemLabel($e)}
- ) - - return $test + ) + + return + $test }; let $uri := request:get-parameter('uri', '') -let $target := request:get-parameter('target','') +let $target := request:get-parameter('target', '') let $docUri := substring-before($uri, '#') let $internalId := substring-after($uri, '#') let $doc := doc($docUri) @@ -291,61 +355,105 @@ let $participants := annotation:getParticipants($annot) let $priority := local:getPriority($annot) let $priorityLabel := if ($lang = 'de') - then('Priorität') - else('Priority') +then + ('Priorität') +else + ('Priority') let $categories := local:getCategories($annot) let $categoriesLabel := if ($lang = 'de') - then (if(count($categories) gt 1)then('Kategorien')else('Kategorie')) - else(if(count($categories) gt 1)then('Categories')else('Category')) +then + (if (count($categories) gt 1) then + ('Kategorien') + else + ('Kategorie')) +else + (if (count($categories) gt 1) then + ('Categories') + else + ('Category')) let $sources := eutil:getDocumentsLabelsAsArray($participants, $edition) let $sourcesLabel := if ($lang = 'de') - then (if(count($sources) gt 1)then('Quellen')else('Quelle')) - else(if(count($sources) gt 1)then('Sources')else('Source')) +then + (if (count($sources) gt 1) then + ('Quellen') + else + ('Quelle')) +else + (if (count($sources) gt 1) then + ('Sources') + else + ('Source')) let $sigla := source:getSiglaAsArray($participants) let $siglaLabel := if ($lang = 'de') - then (if(count($sigla) gt 1)then('Siglen')else('Siglum')) - else(if(count($sigla) gt 1)then('Sources')else('Source')) - +then + (if (count($sigla) gt 1) then + ('Siglen') + else + ('Siglum')) +else + (if (count($sigla) gt 1) then + ('Sources') + else + ('Source')) + let $annotIDlabel := if ($lang = 'de') - then ('Anm.-ID') - else ('Annot.-ID') +then + ('Anm.-ID') +else + ('Annot.-ID') return - if($target eq 'view') - then( - -
-
-
-
{$priorityLabel}
-
{$priority}
+ if ($target eq 'view') + then + ( + +
+
+
+
{$priorityLabel}
+
{$priority}
-
-
{$categoriesLabel}
-
{string-join($categories, ', ')}
+
+
{$categoriesLabel}
+
{string-join($categories, ', ')}
-
-
{$siglaLabel}
-
{string-join($sigla, ', ')}
+
+
{$siglaLabel}
+
{string-join($sigla, ', ')}
-
-
{$annotIDlabel}
-
{$internalId}
+
+
{$annotIDlabel}
+
{$internalId}
-
+

{eutil:getLocalizedName($annot, $lang)}

- {annotation:getContent($annot,'', $edition)} + {annotation:getContent($annot, '', $edition)}
- - - +
- ) - else( -
-
-
-
{$priorityLabel}
-
{$priority}
+ ) + else + ( +
+
+
+
{$priorityLabel}
+
{$priority}
-
-
{$categoriesLabel}
-
{string-join($categories, ', ')}
+
+
{$categoriesLabel}
+
{string-join($categories, ', ')}
-
-
{$siglaLabel}
-
{string-join($sigla, ', ')}
+
+
{$siglaLabel}
+
{string-join($sigla, ', ')}
-
-
{$annotIDlabel}
-
{$internalId}
+
+
{$annotIDlabel}
+
{$internalId}
-
+
{ - if($annot/mei:annot) - then( + if ($annot/mei:annot) + then + ( for $a in $annot/mei:annot return (

{eutil:getLocalizedTitle($annot, $lang)}

, - annotation:getContent($a,'', $edition)) - ) - else( + annotation:getContent($a, '', $edition)) + ) + else + ( (

{eutil:getLocalizedTitle($annot, $lang)}

, - annotation:getContent($annot,'', $edition)) - ) + annotation:getContent($annot, '', $edition)) + ) }
-
- ) \ No newline at end of file + ) \ No newline at end of file diff --git a/add/data/xql/getAnnotationInfos.xql b/add/data/xql/getAnnotationInfos.xql index 4b5775baf..8e5513f5f 100644 --- a/add/data/xql/getAnnotationInfos.xql +++ b/add/data/xql/getAnnotationInfos.xql @@ -21,29 +21,29 @@ declare variable $edition_path := eutil:getPreference('edition_path', $edition); : Returns distinct list of catagories :) declare function local:getDistinctCategories($annots as element()*) as xs:string* { - - let $oldCats := distinct-values($annots/mei:ptr[@type = "categories"]/replace(@target, '#', '')) - let $newCats := distinct-values(for $annot in $annots - return - tokenize(replace(normalize-space($annot/@class), '#', ''), ' '))[contains(., 'annotation.category')] - - return - distinct-values(($oldCats, $newCats)[string-length() gt 0]) + + let $oldCats := distinct-values($annots/mei:ptr[@type = "categories"]/replace(@target, '#', '')) + let $newCats := distinct-values(for $annot in $annots + return + tokenize(replace(normalize-space($annot/@class), '#', ''), ' '))[contains(., 'annotation.category')] + + return + distinct-values(($oldCats, $newCats)[string-length() gt 0]) }; (:~ : Returns distinct list of annotation priorities :) declare function local:getDistinctPriorities($annots as element()*) as xs:string* { - - distinct-values( - for $annot in $annots - let $oldLink := $annot/mei:ptr[@type = "priority"]/replace(@target, '#', '') - let $classes := tokenize(replace(normalize-space($annot/@class), '#', ''), ' ') - let $newLink := $classes[starts-with(., 'ediromAnnotPrio')] - return - distinct-values(($oldLink, $newLink))[string-length(.) gt 0] - ) + + distinct-values( + for $annot in $annots + let $oldLink := $annot/mei:ptr[@type = "priority"]/replace(@target, '#', '') + let $classes := tokenize(replace(normalize-space($annot/@class), '#', ''), ' ') + let $newLink := $classes[starts-with(., 'ediromAnnotPrio')] + return + distinct-values(($oldLink, $newLink))[string-length(.) gt 0] + ) }; let $mei := doc($uri)/root() @@ -52,34 +52,34 @@ let $categories := for $category in local:getDistinctCategories($annots) let $categoryElement := (collection($edition_path)/id($category)[mei:label or mei:name])[1] let $name := annotation:category_getName($categoryElement, eutil:getLanguage($edition)) - order by $name + order by $name return - map { - 'id': $category, - 'name': $name - } + map { + 'id': $category, + 'name': $name + } let $prios := for $priority in local:getDistinctPriorities($annots) let $name := annotation:getPriorityLabel((collection($edition_path)//id($priority)[mei:label or mei:name])[1]) - order by $name + order by $name return - map { - 'id': $priority, - 'name': $name - } + map { + 'id': $priority, + 'name': $name + } let $map := map { - 'categories': array {$categories}, - 'priorities': array {$prios}, - 'count': count($annots) + 'categories': array {$categories}, + 'priorities': array {$prios}, + 'count': count($annots) } return - $map - - (: + $map + + (: return concat('{categories: [', string-join( diff --git a/add/data/xql/getAnnotationMeta.xql b/add/data/xql/getAnnotationMeta.xql index d181fe603..5f7911245 100644 --- a/add/data/xql/getAnnotationMeta.xql +++ b/add/data/xql/getAnnotationMeta.xql @@ -25,16 +25,16 @@ xquery version "3.0"; @author Johannes Kepper :) -import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; -import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; +import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace exist="http://exist.sourceforge.net/NS/exist"; -declare namespace edirom_image="http://www.edirom.de/ns/image"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace exist = "http://exist.sourceforge.net/NS/exist"; +declare namespace edirom_image = "http://www.edirom.de/ns/image"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "xhtml"; @@ -51,52 +51,80 @@ let $annot := $doc/id($internalId) let $participants := annotation:getParticipants($annot) let $priority := annotation:getPriorityLabel($annot) -let $priorityLabel := switch($priority) - case "" return () - default return eutil:getLanguageString('view.window.AnnotationView_Priority', ()) +let $priorityLabel := switch ($priority) + case "" + return + () + default return + eutil:getLanguageString('view.window.AnnotationView_Priority', ()) let $categories := annotation:getCategoriesAsArray($annot) -let $categoriesLabel := switch(count($categories)) - case 0 return () - case 1 return eutil:getLanguageString('view.window.AnnotationView_Category', ()) - default return eutil:getLanguageString('view.window.AnnotationView_Categories', ()) +let $categoriesLabel := switch (count($categories)) + case 0 + return + () + case 1 + return + eutil:getLanguageString('view.window.AnnotationView_Category', ()) + default return + eutil:getLanguageString('view.window.AnnotationView_Categories', ()) let $sources := eutil:getDocumentsLabelsAsArray($participants, $edition) let $sourcesLabel := if (count($sources) gt 1) - then (eutil:getLanguageString('view.window.AnnotationView_Sources', ())) - else (eutil:getLanguageString('view.window.AnnotationView_Source', ())) +then + (eutil:getLanguageString('view.window.AnnotationView_Sources', ())) +else + (eutil:getLanguageString('view.window.AnnotationView_Source', ())) let $sigla := source:getSiglaAsArray($participants) -let $siglaLabel := switch(count($sigla)) - case 0 return () - case 1 return eutil:getLanguageString('view.window.AnnotationView_Source', ())(:TODO check for lang key:) - default return eutil:getLanguageString('view.window.AnnotationView_Sources', ()) +let $siglaLabel := switch (count($sigla)) + case 0 + return + () + case 1 + return + eutil:getLanguageString('view.window.AnnotationView_Source', ()) (:TODO check for lang key:) + default return + eutil:getLanguageString('view.window.AnnotationView_Sources', ()) let $annotIDlabel := eutil:getLanguageString('view.window.AnnotationView_AnnotationID', ()) return - -
-
-
-
{$priorityLabel}
-
{$priority}
+ +
+
+
+
{$priorityLabel}
+
{$priority}
-
-
{$categoriesLabel}
-
{string-join($categories, ', ')}
+
+
{$categoriesLabel}
+
{string-join($categories, ', ')}
-
-
{$siglaLabel}
-
{string-join($sigla, ', ')}
+
+
{$siglaLabel}
+
{string-join($sigla, ', ')}
-
-
{$annotIDlabel}
-
{$internalId}
+
+
{$annotIDlabel}
+
{$internalId}
- \ No newline at end of file diff --git a/add/data/xql/getAnnotationOpenAllUris.xql b/add/data/xql/getAnnotationOpenAllUris.xql index 328727ee6..8c67b8d69 100644 --- a/add/data/xql/getAnnotationOpenAllUris.xql +++ b/add/data/xql/getAnnotationOpenAllUris.xql @@ -18,10 +18,10 @@ xquery version "3.0"; along with Edirom Online. If not, see . :) -import module namespace source="http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; -import module namespace teitext="http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; +import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm"; +import module namespace teitext = "http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "text"; @@ -30,34 +30,45 @@ declare option output:media-type "text/html"; declare function local:getParticipants($annot as element()) as xs:string* { let $participants := tokenize($annot/string(@plist), ' ') - let $docs := distinct-values(for $p in $participants return substring-before($p, '#')) + let $docs := distinct-values(for $p in $participants + return + substring-before($p, '#')) return for $doc in $docs return - if(source:isSource($doc)) - then(local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - - else if(teitext:isText($doc)) - then(string-join($participants[starts-with(., $doc)], $doc), ' ') + if (source:isSource($doc)) + then + (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - else() + else + if (teitext:isText($doc)) + then + (string-join($participants[starts-with(., $doc)], $doc), ' ') + + else + () }; declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as xs:string* { let $elems := for $p in $participants - let $id := substring-after($p, '#') - let $elem := doc($doc)/id($id) - order by count($elem/preceding::*) - return $elem - + let $id := substring-after($p, '#') + let $elem := doc($doc)/id($id) + order by count($elem/preceding::*) + return + $elem + return string-join( - (for $elem in $elems[local-name() != 'measure'] - return concat($doc, '#', $elem/@xml:id) - , - if(count($elems[local-name() = 'measure']) gt 0)then(local:groupSourceParticipants($elems[local-name() = 'measure'], $doc))else() - ) + (for $elem in $elems[local-name() != 'measure'] + return + concat($doc, '#', $elem/@xml:id) + , + if (count($elems[local-name() = 'measure']) gt 0) then + (local:groupSourceParticipants($elems[local-name() = 'measure'], $doc)) + else + () + ) , ' ') }; @@ -67,24 +78,32 @@ declare function local:groupSourceParticipants($elems as node()*, $doc as xs:str for $startId in distinct-values($startIds) let $elem := $elems/id($startId) let $measureCount := count(index-of($startIds, $startId)) - 1 - let $tstamp2 := if($measureCount gt 0) - then(concat('?tstamp2=', $measureCount, 'm+0')) - else('') + let $tstamp2 := if ($measureCount gt 0) + then + (concat('?tstamp2=', $measureCount, 'm+0')) + else + ('') let $isInPart := exists(doc($doc)/id($startId)/ancestor::mei:part) return if ($isInPart) - then concat($doc, '#measure_', $elem/ancestor::mei:mdiv/@xml:id, '_', $elem/@n, $tstamp2) - else concat($doc, '#', $startId, $tstamp2) + then + concat($doc, '#measure_', $elem/ancestor::mei:mdiv/@xml:id, '_', $elem/@n, $tstamp2) + else + concat($doc, '#', $startId, $tstamp2) }; declare function local:getStartIdsOfRange($elems as node()*, $pos as xs:integer, $id as xs:string) as xs:string* { - if($elems[$pos]) - then( - if(count($elems[$pos - 1]/preceding::mei:measure) = count($elems[$pos]/preceding::mei:measure) - 1) - then(($id, local:getStartIdsOfRange($elems, $pos + 1, $id))) - else(($elems[$pos]/string(@xml:id), local:getStartIdsOfRange($elems, $pos + 1, $elems[$pos]/string(@xml:id)))) - ) - else() + if ($elems[$pos]) + then + ( + if (count($elems[$pos - 1]/preceding::mei:measure) = count($elems[$pos]/preceding::mei:measure) - 1) + then + (($id, local:getStartIdsOfRange($elems, $pos + 1, $id))) + else + (($elems[$pos]/string(@xml:id), local:getStartIdsOfRange($elems, $pos + 1, $elems[$pos]/string(@xml:id)))) + ) + else + () }; let $uri := request:get-parameter('uri', '') @@ -93,5 +112,5 @@ let $doc := doc($uri) let $annot := $doc/id($annotId) return - string-join(local:getParticipants($annot),' + string-join(local:getParticipants($annot), ' ') \ No newline at end of file diff --git a/add/data/xql/getAnnotationParticipants.xql b/add/data/xql/getAnnotationParticipants.xql index e3fc191fc..f780eee3d 100644 --- a/add/data/xql/getAnnotationParticipants.xql +++ b/add/data/xql/getAnnotationParticipants.xql @@ -24,7 +24,7 @@ xquery version "1.0"; @author Daniel Röwenstrunk :) -declare namespace request="http://exist-db.org/xquery/request"; +declare namespace request = "http://exist-db.org/xquery/request"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "text"; @@ -43,9 +43,10 @@ let $map := map { } let $options := - map { - 'method': 'json', - 'media-type': 'text/plain' - } +map { + 'method': 'json', + 'media-type': 'text/plain' +} -return serialize($map, $options) +return + serialize($map, $options) diff --git a/add/data/xql/getAnnotationPreviews.xql b/add/data/xql/getAnnotationPreviews.xql index 577b3e3ea..49b87da3e 100644 --- a/add/data/xql/getAnnotationPreviews.xql +++ b/add/data/xql/getAnnotationPreviews.xql @@ -33,7 +33,7 @@ else (eutil:getPreference('image_prefix', $edition)); declare function local:getParticipants($annot as element()) as map(*)* { - + let $participants := tokenize($annot/string(@plist), ' ') let $docs := distinct-values(for $p in $participants return @@ -45,18 +45,18 @@ declare function local:getParticipants($annot as element()) as map(*)* { if (source:isSource($doc)) then (local:getSourceParticipants($participants[starts-with(., $doc)], $doc)) - + else if (teitext:isText($doc)) then (local:getTextParticipants($participants[starts-with(., $doc)], $doc)) - + else () }; declare function local:getTextParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - + for $participant in $participants let $id := substring-after($participant, '#') let $hiddenData := concat('uri:', $doc, '__$$__participantId:', $id) @@ -100,14 +100,14 @@ declare function local:getTextNotePrecedingContent($elem as element()) as xs:str }; declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as map(*)* { - + let $combs := local:groupParticipants($participants, $doc) - + return - + for $comb in distinct-values($combs) let $partIndices := tokenize($comb, '-') - + let $elems := for $p in distinct-values($partIndices) let $relevant.participant := $participants[starts-with(., $doc)][number($p)] @@ -118,16 +118,16 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a order by count($elem/preceding::*) return $elem - + where count($elems) gt 0 - + let $zones := for $elem in $elems return local:getZone($elem) - + let $type := local:getType($zones) let $label := local:getItemLabel($elems) - + let $mdiv := '' (: TODO if($elem/ancestor-or-self::mei:mdiv) then($elem/ancestor-or-self::mei:mdiv/@label) else(''):) let $page := if ($zones[1]/parent::mei:surface/@label != '') then ($zones[1]/parent::mei:surface/string(@label)) @@ -135,20 +135,20 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a ($zones[1]/parent::mei:surface/string(@n)) let $sourceLabel := source:getLabel($doc, $edition) let $siglum := ($elems[1]/root()//mei:*[@type eq 'siglum'])[1]/text() - + let $part := string-join(distinct-values(for $e in $elems return $e/ancestor::mei:part/string(@label)), '-') - + let $graphic := $zones[1]/../mei:graphic[@type = 'facsimile'] let $imgWidth := number($graphic/@width) let $imgHeight := number($graphic/@height) - + let $digilibBaseParams := local:getImageAreaPath($imageBasePath, $graphic) let $rect := local:getBoundingZone($zones) - + let $digilibSizeParams := local:getImageAreaParams($rect, $imgWidth, $imgHeight) - + let $hiddenData := map { 'width': number($rect/@lrx) - number($rect/@ulx), 'height': number($rect/@lry) - number($rect/@uly), @@ -157,9 +157,9 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a 'origH': $imgHeight, 'origW': $imgWidth } - + let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones)) - + return map { 'type': $type, @@ -198,20 +198,20 @@ declare function local:getSourceLinkTarget($elems as node()*, $zones as node()*) }; declare function local:groupParticipants($participants as xs:string*, $doc as xs:string) as xs:string* { - + let $elems := for $p in $participants let $id := substring-after($p, '#') return doc($doc)/id($id) - + let $zones := for $elem in $elems return local:getZone($elem) - + let $combs := for $p at $i in $participants return local:getCombinations($elems, $zones, $i, count($zones)) - + return reverse( for $comb at $i in reverse($combs) @@ -232,7 +232,7 @@ declare function local:groupParticipants($participants as xs:string*, $doc as xs }; declare function local:getCombinations($elems as element()*, $zones as element()*, $i as xs:int, $total as xs:int) as xs:string { - + let $currentZone := $zones[$i] let $currentElem := $elems[$i] return @@ -257,7 +257,7 @@ declare function local:getCombinations($elems as element()*, $zones as element() }; declare function local:compareZones($zone1 as element(), $zone2 as element()) as xs:boolean { - + let $samePage := deep-equal($zone1/.., $zone2/..) let $overlapping := not(number($zone1/@ulx) gt number($zone2/@lrx) or number($zone1/@lrx) lt number($zone2/@ulx) or number($zone1/@uly) gt number($zone2/@lry) or number($zone1/@lry) lt number($zone2/@uly)) return @@ -267,7 +267,7 @@ declare function local:compareZones($zone1 as element(), $zone2 as element()) as declare function local:getElement($uri as xs:string) as element()? { let $doc := substring-before($uri, '#') let $id := substring-after($uri, '#') - + return doc($doc)/id($id) }; @@ -314,17 +314,17 @@ declare function local:getBoundingZone($zones as element()*) as element() { :) declare function local:getImageAreaPath($basePath as xs:string, $graphic as element()?) as xs:string { - + let $imagePath := string($graphic/@target) let $imgWidth := number($graphic/@width) let $imgHeight := number($graphic/@height) let $isAbsolute := starts-with($imagePath, 'http') - + let $fields := if ($imageserver = 'leaflet') then (substring-before($imagePath, '.')) else () - + return if ($isAbsolute) then @@ -355,17 +355,17 @@ declare function local:getImageAreaPath($basePath as xs:string, $graphic as elem :) declare function local:getImageAreaParams($zone as element()?, $imgWidth as xs:int, $imgHeight as xs:int) as xs:string { let $graphic := $zone/../mei:graphic[@type = 'facsimile'] - + let $imgX := number($zone/@ulx) let $imgY := number($zone/@uly) let $w := number($zone/@lrx) - number($zone/@ulx) let $h := number($zone/@lry) - number($zone/@uly) - + let $wx := $imgX div $imgWidth let $wy := $imgY div $imgHeight let $ww := $w div $imgWidth let $wh := $h div $imgHeight - + return concat('&wx=', $wx, '&wy=', $wy, '&ww=', $ww, '&wh=', $wh, '&mo=fit') }; @@ -406,9 +406,9 @@ declare function local:getItemLabel($elems as element()*) as xs:string { if (count($items) gt 1) then ( - + let $measureNs := distinct-values($items/ancestor::mei:measure/@n) - + let $label := if ($lang = 'de') then (if (count($measureNs) gt 1) then @@ -420,11 +420,11 @@ declare function local:getItemLabel($elems as element()*) as xs:string { (concat('Bars ', $measureNs[1], '-', $measureNs[last()])) else (concat('Bar ', $measureNs[1]))) - + return - + concat($label, ' (', string-join($items/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ', '), ')') - + ) else (concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')')) diff --git a/add/data/xql/getAnnotationText.xql b/add/data/xql/getAnnotationText.xql index 2a7235350..24b42197b 100644 --- a/add/data/xql/getAnnotationText.xql +++ b/add/data/xql/getAnnotationText.xql @@ -25,14 +25,14 @@ xquery version "1.0"; @author Johannes Kepper :) -import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace edirom_image="http://www.edirom.de/ns/image"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace edirom_image = "http://www.edirom.de/ns/image"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "xhtml"; @@ -50,9 +50,11 @@ let $annot := $doc/id($internalId) return -
-
+
+

{eutil:getLocalizedName($annot, $lang)}

- {annotation:getContent($annot, '', $edition)} + {annotation:getContent($annot, '', $edition)}
\ No newline at end of file diff --git a/add/data/xql/getAnnotations.xql b/add/data/xql/getAnnotations.xql index 99a73d40b..57730e9c7 100644 --- a/add/data/xql/getAnnotations.xql +++ b/add/data/xql/getAnnotations.xql @@ -26,11 +26,11 @@ xquery version "3.1"; : @author Daniel Röwenstrunk :) -import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; +import module namespace annotation = "http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "text"; @@ -38,18 +38,22 @@ declare option output:media-type "text/plain"; let $edition := request:get-parameter('edition', '') let $uri := request:get-parameter('uri', '') -let $uri := if(contains($uri, '#')) then(substring-before($uri, '#')) else($uri) - -let $map := - map { - 'success': true(), - 'total': count(doc($uri)//mei:annot[@type = 'editorialComment']), - 'annotations': array { annotation:annotationsToJSON($uri, $edition)} - } +let $uri := if (contains($uri, '#')) then + (substring-before($uri, '#')) +else + ($uri) + +let $map := +map { + 'success': true(), + 'total': count(doc($uri)//mei:annot[@type = 'editorialComment']), + 'annotations': array {annotation:annotationsToJSON($uri, $edition)} +} let $options := - map { - 'method': 'json', - 'media-type': 'text/plain' - } - -return serialize($map, $options) \ No newline at end of file +map { + 'method': 'json', + 'media-type': 'text/plain' +} + +return + serialize($map, $options) \ No newline at end of file diff --git a/add/data/xql/getAnnotationsInRendering.xql b/add/data/xql/getAnnotationsInRendering.xql index 78d744e85..4016c3607 100644 --- a/add/data/xql/getAnnotationsInRendering.xql +++ b/add/data/xql/getAnnotationsInRendering.xql @@ -28,36 +28,36 @@ xquery version "3.0"; import module namespace functx = "http://www.functx.com"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace request="http://exist-db.org/xquery/request"; +declare namespace request = "http://exist-db.org/xquery/request"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; declare function local:getAnnotations($edition as xs:string, $edition_path as xs:string, $uri as xs:string, $elemIds as xs:string*) as xs:string* { for $measureId in $elemIds - let $uriPlusId := concat($uri, '#', $measureId) - let $annots := collection($edition_path)//mei:annot/@plist[tokenize(string(.), '\s+') = $uriPlusId]/.. - return + let $uriPlusId := concat($uri, '#', $measureId) + let $annots := collection($edition_path)//mei:annot/@plist[tokenize(string(.), '\s+') = $uriPlusId]/.. + return for $annotation in $annots - let $id := $annotation/string(@xml:id) - let $uri := concat('xmldb:exist://', document-uri($annotation/root()), '#', $id) - let $prio := $annotation/mei:ptr[@type="priority"]/replace(@target, '#', '') - let $cat := $annotation/mei:ptr[@type="categories"]/replace(@target, '#', '') - return - concat(' + let $id := $annotation/string(@xml:id) + let $uri := concat('xmldb:exist://', document-uri($annotation/root()), '#', $id) + let $prio := $annotation/mei:ptr[@type = "priority"]/replace(@target, '#', '') + let $cat := $annotation/mei:ptr[@type = "categories"]/replace(@target, '#', '') + return + concat(' {', - '"id": "', $id, '", ', - '"measureId": "', $measureId, '", ', - '"fn": "loadLink(\"', $uri, '\")", ', - '"uri": "', $uri, '", ', - '"priority": "', $prio, '", ', - '"categories": "', $cat, '"', - '}') + '"id": "', $id, '", ', + '"measureId": "', $measureId, '", ', + '"fn": "loadLink(\"', $uri, '\")", ', + '"uri": "', $uri, '", ', + '"priority": "', $prio, '", ', + '"categories": "', $cat, '"', + '}') }; @@ -68,8 +68,9 @@ let $measureIds := request:get-parameter('measureIds', '') let $edition_path := eutil:getPreference('edition_path', $edition) let $annots := local:getAnnotations($edition, $edition_path, $uri, tokenize($measureIds, ',')) -return ( +return + ( concat('[', - string-join($annots, ','), + string-join($annots, ','), ']') -) + ) diff --git a/add/data/xql/getAnnotationsInText.xql b/add/data/xql/getAnnotationsInText.xql index d57ed2704..b387a9f82 100644 --- a/add/data/xql/getAnnotationsInText.xql +++ b/add/data/xql/getAnnotationsInText.xql @@ -26,12 +26,12 @@ xquery version "1.0"; @author Daniel Röwenstrunk :) -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace ft="http://exist-db.org/xquery/lucene"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace ft = "http://exist-db.org/xquery/lucene"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; @@ -42,35 +42,37 @@ declare option exist:serialize "method=text media-type=text/plain omit-xml-decla @returns A sequence of annotation elements :) declare function local:findAnnotations($uri as xs:string) as element()* { - + (: TODO: check if annotations hold URIs or IDRefs :) - collection('/db/contents')//mei:annot[matches(@plist, $uri)] + collection('/db/contents')//mei:annot[matches(@plist, $uri)] }; declare function local:getAnnotations($uriSharp as xs:string, $annotations as element()*) as xs:string* { for $annotation in $annotations - let $id := $annotation/string(@xml:id) - let $uri := concat('xmldb:exist://', document-uri($annotation/root()), '#', $id) - let $prio := $annotation/mei:ptr[@type="priority"]/replace(@target, '#', '') - let $cat := $annotation/mei:ptr[@type="categories"]/replace(@target, '#', '') - let $plist := for $p in tokenize($annotation/@plist, '\s+') - return - if(starts-with($p, $uriSharp)) - then(concat('{id:"', $id, '__', substring-after($p, $uriSharp),'"}')) - else() - let $plist := string-join($plist, ',') - return - concat(' + let $id := $annotation/string(@xml:id) + let $uri := concat('xmldb:exist://', document-uri($annotation/root()), '#', $id) + let $prio := $annotation/mei:ptr[@type = "priority"]/replace(@target, '#', '') + let $cat := $annotation/mei:ptr[@type = "categories"]/replace(@target, '#', '') + let $plist := for $p in tokenize($annotation/@plist, '\s+') + return + if (starts-with($p, $uriSharp)) + then + (concat('{id:"', $id, '__', substring-after($p, $uriSharp), '"}')) + else + () + let $plist := string-join($plist, ',') + return + concat(' {', - 'id: "', $id, '", ', - 'plist: [', $plist, '], ', - 'svgList: [], ', - 'fn: "loadLink(\"', $uri, '\")", ', - 'uri: "', $uri, '", ', - 'priority: "', $prio, '", ', - 'categories: "', $cat, '"', - '}') + 'id: "', $id, '", ', + 'plist: [', $plist, '], ', + 'svgList: [], ', + 'fn: "loadLink(\"', $uri, '\")", ', + 'uri: "', $uri, '", ', + 'priority: "', $prio, '", ', + 'categories: "', $cat, '"', + '}') }; let $uri := request:get-parameter('uri', '') @@ -79,5 +81,5 @@ let $annotations := local:findAnnotations($uri) return concat('[', - string-join(local:getAnnotations($uriSharp, $annotations), ','), + string-join(local:getAnnotations($uriSharp, $annotations), ','), ']') diff --git a/add/data/xql/getAnnotationsOnPage.xql b/add/data/xql/getAnnotationsOnPage.xql index 0dbba5837..6cb1373f9 100644 --- a/add/data/xql/getAnnotationsOnPage.xql +++ b/add/data/xql/getAnnotationsOnPage.xql @@ -29,15 +29,15 @@ xquery version "3.1"; import module namespace functx = "http://www.functx.com"; -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; -declare namespace svg="http://www.w3.org/2000/svg"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; +declare namespace svg = "http://www.w3.org/2000/svg"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace ft="http://exist-db.org/xquery/lucene"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace ft = "http://exist-db.org/xquery/lucene"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "json"; @@ -53,33 +53,37 @@ declare option output:media-type "application/json"; declare function local:getAnnotations($sourceUriSharp as xs:string, $surfaceId as xs:string, $annotations as element()*, $elems as element()*) as map(*)* { for $annotation in $annotations - let $id := $annotation/string(@xml:id) - let $uri := concat('xmldb:exist://', document-uri($annotation/root()), '#', $id) - let $classes := tokenize(replace(normalize-space($annotation/@class),'#',''),' ') - let $prio := $annotation/mei:ptr[@type="priority"]/replace(@target, '#', '') || $classes[starts-with(.,'ediromAnnotPrio')] - let $cat := $annotation/mei:ptr[@type="categories"]/replace(@target, '#', '') || string-join($classes[contains(.,'annotation.category.')],' ') - let $plist.raw := - for $p in tokenize(normalize-space($annotation/@plist), ' ') - let $p.noSharp := replace($p,'#','') - return - if(starts-with($p, $sourceUriSharp)) - then(substring-after($p, $sourceUriSharp)) - else if($elems/@xml:id[. = $p.noSharp] or $elems/@id[. = $p.noSharp]) - then($p.noSharp) - else() + let $id := $annotation/string(@xml:id) + let $uri := concat('xmldb:exist://', document-uri($annotation/root()), '#', $id) + let $classes := tokenize(replace(normalize-space($annotation/@class), '#', ''), ' ') + let $prio := $annotation/mei:ptr[@type = "priority"]/replace(@target, '#', '') || $classes[starts-with(., 'ediromAnnotPrio')] + let $cat := $annotation/mei:ptr[@type = "categories"]/replace(@target, '#', '') || string-join($classes[contains(., 'annotation.category.')], ' ') + let $plist.raw := + for $p in tokenize(normalize-space($annotation/@plist), ' ') + let $p.noSharp := replace($p, '#', '') + return + if (starts-with($p, $sourceUriSharp)) + then + (substring-after($p, $sourceUriSharp)) + else + if ($elems/@xml:id[. = $p.noSharp] or $elems/@id[. = $p.noSharp]) + then + ($p.noSharp) + else + () let $svgList := local:getAnnotSVGs($id, $plist.raw, $elems) let $plist := local:getParticipants($id, $plist.raw, $elems) - return - map { - 'id': $id, - 'plist': array { $plist }, - 'svgList': array { $svgList }, - 'fn': 'loadLink("' || $uri || '")', - 'uri': $uri, - 'priority': $prio, - 'categories': $cat - } - + return + map { + 'id': $id, + 'plist': array {$plist}, + 'svgList': array {$svgList}, + 'fn': 'loadLink("' || $uri || '")', + 'uri': $uri, + 'priority': $prio, + 'categories': $cat + } + }; (:~ @@ -91,22 +95,22 @@ declare function local:getAnnotations($sourceUriSharp as xs:string, $surfaceId a : @returns A sequence of mei:annot elements :) declare function local:findAnnotations($edition as xs:string, $uri as xs:string, $elemIds as xs:string*) as element()* { - + (: TODO: search in other documents and in other collections :) (: TODO: check if annotations hold URIs or IDRefs :) - functx:distinct-deep( - for $id in $elemIds - let $uriPlusId := concat($uri, '#', $id) - let $hashId := '#' || $id - let $annots := collection(eutil:getPreference('edition_path', $edition))//mei:annot - return - (: + functx:distinct-deep( + for $id in $elemIds + let $uriPlusId := concat($uri, '#', $id) + let $hashId := '#' || $id + let $annots := collection(eutil:getPreference('edition_path', $edition))//mei:annot + return + (: The first predicate with `contains` is just a rough estimate to narrow down the result set. It uses the index and is fast while the second (exact) predicate is generally too slow :) - $annots[contains(@plist, $uriPlusId)][$uriPlusId = tokenize(@plist, '\s')] | - $annots[contains(@plist, $hashId)][$hashId = tokenize(@plist, '\s')] - ) + $annots[contains(@plist, $uriPlusId)][$uriPlusId = tokenize(@plist, '\s')] | + $annots[contains(@plist, $hashId)][$hashId = tokenize(@plist, '\s')] + ) }; (:~ @@ -118,19 +122,20 @@ declare function local:findAnnotations($edition as xs:string, $uri as xs:string, @returns A JSON representation of the perticipants :) declare function local:getParticipants($annoId as xs:string, $plist as xs:string*, $elems as element()*) as map(*)* { - + let $participants := $elems[@xml:id = $plist] return for $p in $participants let $coord := local:getCoordinates($p) - return map { - 'id': 'annotation__' || string($p/@xml:id), - 'type': string($p/@type), - 'ulx': $coord[1], - 'uly': $coord[2], - 'lrx': $coord[3], - 'lry': $coord[4] - } + return + map { + 'id': 'annotation__' || string($p/@xml:id), + 'type': string($p/@type), + 'ulx': $coord[1], + 'uly': $coord[2], + 'lrx': $coord[3], + 'lry': $coord[4] + } }; (:~ @@ -142,16 +147,17 @@ declare function local:getParticipants($annoId as xs:string, $plist as xs:string @returns A JSON representation of the perticipants :) declare function local:getAnnotSVGs($annoId as xs:string, $plist as xs:string*, $elems as element()*) as map(*)* { - + let $participants := $elems[@id = $plist] return - + for $svg in $participants let $id := $svg/@id - return map { - 'id': $annoId || '__' || $id, - 'svg': $svg - } + return + map { + 'id': $annoId || '__' || $id, + 'svg': $svg + } }; (:~ @@ -161,10 +167,17 @@ declare function local:getAnnotSVGs($annoId as xs:string, $plist as xs:string*, : @returns A sequence with coordinates (ulx, uly, lrx, lry) :) declare function local:getCoordinates($participant as element()) as xs:integer+ { - let $zone := if(name($participant) = 'measure' or name($participant) = 'staff') then($participant/root()/id(substring($participant/@facs, 2))) else($participant) - return if($zone/@ulx) then( - (number($zone/@ulx), number($zone/@uly), number($zone/@lrx), number($zone/@lry)) - )else ((-1, -1, -1, -1)) + let $zone := if (name($participant) = 'measure' or name($participant) = 'staff') then + ($participant/root()/id(substring($participant/@facs, 2))) + else + ($participant) + return + if ($zone/@ulx) then + ( + (number($zone/@ulx), number($zone/@uly), number($zone/@lrx), number($zone/@lry)) + ) + else + ((-1, -1, -1, -1)) }; let $edition := request:get-parameter('edition', '') @@ -176,11 +189,12 @@ let $surfaceId := request:get-parameter('pageId', '') let $surface := $mei/id($surfaceId) let $zones := $surface//mei:zone -let $measureLike := - for $id in $zones[@type = 'measure' or @type = 'staff']/string(@xml:id) - let $ref := concat('#', $id) - return $mei//*[$ref = tokenize(@facs,'\s')] - +let $measureLike := +for $id in $zones[@type = 'measure' or @type = 'staff']/string(@xml:id) +let $ref := concat('#', $id) +return + $mei//*[$ref = tokenize(@facs, '\s')] + let $svgLike := $surface//svg:svg let $targetLike := $zones | $measureLike | $svgLike @@ -190,4 +204,4 @@ let $annotations := local:findAnnotations($edition, $sourceUri, $targetLikeIds) let $annots := local:getAnnotations($sourceUriSharp, $surfaceId, $annotations, $targetLike) return - array { $annots } + array {$annots} diff --git a/add/data/xql/getAudioPlayer.xql b/add/data/xql/getAudioPlayer.xql index ef6eb5eef..05754f338 100644 --- a/add/data/xql/getAudioPlayer.xql +++ b/add/data/xql/getAudioPlayer.xql @@ -18,247 +18,342 @@ xquery version "3.0"; along with Edirom Online. If not, see . :) -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; let $uri := request:get-parameter('uri', '') -let $docUri := if(contains($uri, '#')) then(substring-before($uri, '#')) else($uri) +let $docUri := if (contains($uri, '#')) then + (substring-before($uri, '#')) +else + ($uri) let $doc := eutil:getDoc($docUri) -let $artist := $doc//mei:titleStmt/mei:respStmt/mei:persName[@role='artist'] +let $artist := $doc//mei:titleStmt/mei:respStmt/mei:persName[@role = 'artist'] let $album := $doc//mei:meiHead/mei:fileDesc/mei:sourceDesc/mei:source[1]/mei:titleStmt/mei:title[1]/text() -let $albumCover := $doc//mei:graphic[@type='cover']/string(@target) +let $albumCover := $doc//mei:graphic[@type = 'cover']/string(@target) let $records := for $rec in $doc//mei:recording - let $recSource := $doc//mei:source[@xml:id = substring-after($rec/@decls, '#')] - let $recTitle := $recSource/mei:titleStmt/mei:title - let $avFile := $rec/mei:avFile[1]/string(@target) - return - '{ +let $recSource := $doc//mei:source[@xml:id = substring-after($rec/@decls, '#')] +let $recTitle := $recSource/mei:titleStmt/mei:title +let $avFile := $rec/mei:avFile[1]/string(@target) +return + '{ "name": "' || replace($recTitle, '"', '\\"') || '" ,"artist": "' || replace($artist, '"', '\\"') || '" ,"album": "' || replace($album, '"', '\\"') || '" ,"url": "' || $avFile || '" ,"live": false' || - ',"cover_art_url": "' || $albumCover || '"' || ' + ',"cover_art_url": "' || $albumCover || '"' || ' }' let $audioConfig := '{ "songs": [' || - string-join($records, ', ') - || '], +string-join($records, ', ') +|| '], "default_album_art": "../../resources/img/no-cover.png" }' return - - - - - - - - - - - - - -
-
- -
-
-
-
- - - -
- -
- - - -
- -
- -
- - - - - - - -
-
- -
-
-
-
-
- - - -
-
-
-
-
- -
- -
-
-
-
- - - -
-
- - 0:00 - -
- - - -
-
-
-
-
-
-
-
- - 0:00 - - -
- - - 0:00 - -
-
- -
- - - -
-
- {$artist} – {$album} -
-
- { - for $rec at $i in $doc//mei:recording - let $recSource := $doc//mei:source[@xml:id = substring-after($rec/@decls, '#')] - let $recTitle := $recSource/mei:titleStmt/mei:title/text() - let $avFile := '../../../exist/apps/contents/audioData/' || $rec/mei:avFile[2]/string(@target) - return + + + + + + + + + + + + + +
+
-
-
-
{$recTitle}
-
{$artist} – {$album}
-
-
-
- } -
- - - - +
+
-
+
+ + + +
+ +
+ + + +
+ +
+ +
+ + + + + + + +
+
+ +
+
+
+
+
+ + + +
+
+
-
+
+ +
+ +
+
+
+
+ + + +
+
+ + 0:00 + +
+ + + +
+
+
+
+
+
+
+
+ + 0:00 + + +
+ + + 0:00 + +
+
+ +
+ + + +
+
+ {$artist} – {$album} +
+
+ { + for $rec at $i in $doc//mei:recording + let $recSource := $doc//mei:source[@xml:id = substring-after($rec/@decls, '#')] + let $recTitle := $recSource/mei:titleStmt/mei:title/text() + let $avFile := '../../../exist/apps/contents/audioData/' || $rec/mei:avFile[2]/string(@target) + return + +
+
+
{$recTitle}
+
{$artist} – {$album}
+
+
+
+ } +
+ + + + diff --git a/add/data/xql/getChapters.xql b/add/data/xql/getChapters.xql index 5fd15933d..88cf9c9d9 100644 --- a/add/data/xql/getChapters.xql +++ b/add/data/xql/getChapters.xql @@ -20,88 +20,135 @@ xquery version "3.0"; ID: $Id: getChapters.xql 1460 2012-10-15 15:58:35Z niko $ :) -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace tei = "http://www.tei-c.org/ns/1.0"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; declare function local:changeFormat($n) as xs:string { - if($n = '1') - then('I') - else if($n = '2') - then('II') - else if($n = '3') - then('III') - else if($n = '4') - then('IV') - else if($n = '5') - then('V') - else if($n = '6') - then('VI') - else if($n = '7') - then('VII') - else if($n = '8') - then('VIII') - else if($n = '9') - then('IX') - else ($n) + if ($n = '1') + then + ('I') + else + if ($n = '2') + then + ('II') + else + if ($n = '3') + then + ('III') + else + if ($n = '4') + then + ('IV') + else + if ($n = '5') + then + ('V') + else + if ($n = '6') + then + ('VI') + else + if ($n = '7') + then + ('VII') + else + if ($n = '8') + then + ('VIII') + else + if ($n = '9') + then + ('IX') + else + ($n) }; let $uri := request:get-parameter('uri', '') let $mode := request:get-parameter('mode', '') let $tei := eutil:getDoc($uri)/root() -let $ret := for $elem in $tei//tei:div[@type='chapter'] | $tei//tei:div1 | $tei//tei:milestone[@unit='number'] | $tei//tei:div[@type='act'] - let $pageId := if($mode = 'pageMode')then(substring-after($elem/preceding::tei:pb[1]/@facs, '#'))else('-1') +let $ret := for $elem in $tei//tei:div[@type = 'chapter'] | $tei//tei:div1 | $tei//tei:milestone[@unit = 'number'] | $tei//tei:div[@type = 'act'] +let $pageId := if ($mode = 'pageMode') then + (substring-after($elem/preceding::tei:pb[1]/@facs, '#')) +else + ('-1') +return + if (($elem/local-name() = 'div' and $elem[@type = 'chapter']) or $elem/local-name() = 'div1') + then + ( + let $chapter := $elem + let $n := if ($chapter/@n) then + (concat($chapter/@n, ': ')) + else + ('') + let $label := if ($chapter/tei:head) then + ($chapter/tei:head) + else + ($chapter/text()) + let $label := if (string-length($label) > 30) then + (concat(substring($label, 1, 30), '…')) + else + ($label) + return + concat('{', + 'id: "', $chapter/string(@xml:id), '", ', + 'name: "', concat($n, $label), '", ', + 'pageId: "', $pageId, '"', + '}') + ) + else + if ($elem/local-name() = 'milestone' and $elem[@unit = 'number']) + then + ( + let $numbers := $elem + let $n := concat('No. ', $numbers/@n) + order by $numbers/number(replace(@n, '\D', '')), + $numbers/@n return - if(($elem/local-name() = 'div' and $elem[@type='chapter']) or $elem/local-name() = 'div1') - then( - let $chapter := $elem - let $n := if($chapter/@n)then(concat($chapter/@n, ': '))else('') - let $label := if($chapter/tei:head)then($chapter/tei:head)else($chapter/text()) - let $label := if(string-length($label) > 30)then(concat(substring($label, 1, 30), '…'))else($label) + concat('{', + 'id: "', $numbers/string(@xml:id), '", ', + 'name: "', $n, '", ', + 'pageId: "', $pageId, '"', + '}') + ) + else + if ($elem/local-name() = 'div' and $elem[@type = 'act']) + then + ( + let $act := $elem + let $label := local:changeFormat($act/@n) + return + for $scene in $act//tei:div[@type = 'scene'] + let $label := $label || ' - ' || string-join(for $t in $scene/tei:head//text() return - concat('{', - 'id: "', $chapter/string(@xml:id), '", ', - 'name: "', concat($n, $label), '", ', - 'pageId: "', $pageId, '"', - '}') - ) - else if($elem/local-name() = 'milestone' and $elem[@unit='number']) - then( - let $numbers := $elem - let $n := concat('No. ', $numbers/@n) - order by $numbers/number(replace(@n, '\D', '')), $numbers/@n + if (matches($t, '\w')) then + ($t) + else + (), '') + let $label := if (string-length($label) > 40) then + (concat(substring($label, 1, 40), '…')) + else + ($label) + let $pageId := if ($mode = 'pageMode') then + (substring-after($scene/preceding::tei:pb[1]/@facs, '#')) + else + ('-1') return concat('{', - 'id: "', $numbers/string(@xml:id), '", ', - 'name: "', $n, '", ', - 'pageId: "', $pageId, '"', + '"id": "', $scene/string(@xml:id), '", ', + '"name": "', $label, '", ', + 'pageId: "', $pageId, '"', '}') ) - else if($elem/local-name() = 'div' and $elem[@type='act']) - then( - let $act := $elem - let $label := local:changeFormat($act/@n) - return - for $scene in $act//tei:div[@type='scene'] - let $label := $label || ' - ' || string-join(for $t in $scene/tei:head//text() - return - if(matches($t, '\w'))then($t)else(), '') - let $label := if(string-length($label) > 40)then(concat(substring($label, 1, 40), '…'))else($label) - let $pageId := if($mode = 'pageMode')then(substring-after($scene/preceding::tei:pb[1]/@facs, '#'))else('-1') - return - concat('{', - '"id": "', $scene/string(@xml:id), '", ', - '"name": "', $label, '", ', - 'pageId: "', $pageId, '"', - '}') - ) - else() + else + () -return concat('[', string-join($ret, ','), ']') \ No newline at end of file +return + concat('[', string-join($ret, ','), ']') \ No newline at end of file diff --git a/add/data/xql/getConcordances.xql b/add/data/xql/getConcordances.xql index c3f26fffe..e2bf1697f 100644 --- a/add/data/xql/getConcordances.xql +++ b/add/data/xql/getConcordances.xql @@ -20,56 +20,60 @@ xquery version "1.0"; ID: $Id: getConcordances.xql 1219 2012-01-20 08:33:28Z daniel $ :) -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace edirom="http://www.edirom.de/ns/1.3"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace edirom = "http://www.edirom.de/ns/1.3"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; declare variable $lang := request:get-parameter('lang', ''); declare function local:getGroups($parent) { - if($parent/edirom:groups) - then( + if ($parent/edirom:groups) + then + ( concat('{', 'label: "', eutil:getLocalizedName($parent/edirom:groups, $lang), '", groups: [', local:getSingleGroups($parent/edirom:groups), ']}') - ) - else(string('null')) + ) + else + (string('null')) }; declare function local:getSingleGroups($parent) { string-join( - for $group in $parent/edirom:group - return - concat(' + for $group in $parent/edirom:group + return + concat(' {', - 'name: "', eutil:getLocalizedName($group, $lang), '", ', - 'connections: ', local:getConnections($group), - '}') + 'name: "', eutil:getLocalizedName($group, $lang), '", ', + 'connections: ', local:getConnections($group), + '}') , ',') }; declare function local:getConnections($parent) { - if($parent/edirom:connections) - then( + if ($parent/edirom:connections) + then + ( concat('{', 'label: "', eutil:getLocalizedName($parent/edirom:connections, $lang), '", connections: [', local:getSingleConnections($parent/edirom:connections), ']}') - ) - else(string('null')) + ) + else + (string('null')) }; declare function local:getSingleConnections($parent) { string-join( - for $connection in $parent/edirom:connection - return - concat(' + for $connection in $parent/edirom:connection + return + concat(' {', - 'name: "', $connection/string(@name), '", ', - 'plist: "', $connection/@plist, '"', - '}') + 'name: "', $connection/string(@name), '", ', + 'plist: "', $connection/@plist, '"', + '}') , ',') }; @@ -79,19 +83,20 @@ let $workId := request:get-parameter('workId', '') let $work := $mei/id($workId) let $concordances := $work//edirom:concordance -return ( +return + ( concat('[', - + string-join( - for $concordance in $concordances - return - concat(' + for $concordance in $concordances + return + concat(' {', - 'name: "', eutil:getLocalizedName($concordance, $lang), '", ', - 'groups: ', local:getGroups($concordance), ', ', - 'connections: ', local:getConnections($concordance), - '}') + 'name: "', eutil:getLocalizedName($concordance, $lang), '", ', + 'groups: ', local:getGroups($concordance), ', ', + 'connections: ', local:getConnections($concordance), + '}') , ','), - + ']') -) + ) diff --git a/add/data/xql/getEdition.xql b/add/data/xql/getEdition.xql index 77bddc6b4..1ab2eee76 100644 --- a/add/data/xql/getEdition.xql +++ b/add/data/xql/getEdition.xql @@ -26,9 +26,10 @@ xquery version "1.0"; : @author Daniel Röwenstrunk :) -import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; +import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; let $uri := request:get-parameter('id', '') -return edition:toJSON($uri) \ No newline at end of file +return + edition:toJSON($uri) \ No newline at end of file diff --git a/add/data/xql/getEditionURI.xql b/add/data/xql/getEditionURI.xql index 22256a695..10ca59704 100644 --- a/add/data/xql/getEditionURI.xql +++ b/add/data/xql/getEditionURI.xql @@ -24,12 +24,14 @@ xquery version "3.0"; : @author Daniel Röwenstrunk :) -import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; +import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; let $uri := request:get-parameter('uri', '') return - if(doc-available($uri)) - then($uri) - else(edition:findEdition($uri)) \ No newline at end of file + if (doc-available($uri)) + then + ($uri) + else + (edition:findEdition($uri)) \ No newline at end of file diff --git a/add/data/xql/getExtendedStaff.xql b/add/data/xql/getExtendedStaff.xql index 05f0674f3..19dfa2813 100644 --- a/add/data/xql/getExtendedStaff.xql +++ b/add/data/xql/getExtendedStaff.xql @@ -1,12 +1,12 @@ xquery version "3.0"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; -declare namespace system="http://exist-db.org/xquery/system"; -declare namespace transform="http://exist-db.org/xquery/transform"; +declare namespace tei = "http://www.tei-c.org/ns/1.0"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; +declare namespace system = "http://exist-db.org/xquery/system"; +declare namespace transform = "http://exist-db.org/xquery/transform"; import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; @@ -20,39 +20,69 @@ let $basePath := eutil:get-app-base-url() let $mei := doc($uri)/root() let $mdivId := $mei//mei:mdiv[1]/data(@xml:id) return - - - Verovio - - - - - - - - - - - - -
-
- - - - 1 / 1 - - - -
-
+ + + Verovio + + + + + + + + + - - - - + + +
+
+ + + + 1 / 1 + + + +
+
+ + + + + diff --git a/add/data/xql/getHeader.xql b/add/data/xql/getHeader.xql index 397ea6215..9efc2e440 100644 --- a/add/data/xql/getHeader.xql +++ b/add/data/xql/getHeader.xql @@ -20,32 +20,59 @@ xquery version "1.0"; ID: $Id: getHeader.xql 1455 2012-10-11 10:42:55Z daniel $ :) -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; -declare namespace system="http://exist-db.org/xquery/system"; -declare namespace transform="http://exist-db.org/xquery/transform"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace tei = "http://www.tei-c.org/ns/1.0"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; +declare namespace system = "http://exist-db.org/xquery/system"; +declare namespace transform = "http://exist-db.org/xquery/transform"; declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; let $uri := request:get-parameter('uri', '') let $type := request:get-parameter('type', '') -let $docUri := if(contains($uri, '#')) then(substring-before($uri, '#')) else($uri) +let $docUri := if (contains($uri, '#')) then + (substring-before($uri, '#')) +else + ($uri) let $doc := eutil:getDoc($docUri) let $lang := request:get-parameter('lang', 'de') let $base := concat(replace(system:get-module-load-path(), 'embedded-eXist-server', ''), '/../xslt/') (: TODO: Prüfen, wie wir an dem replace vorbei kommen:) return - if($type = 'work') - then(transform:transform($doc, concat($base, 'meiHead2HTML.xsl'), )) - else if($type = 'source') - then(transform:transform($doc, concat($base, 'meiHead2HTML.xsl'), )) - else if($type = 'recording') - then(transform:transform($doc, concat($base, 'meiHead2HTML.xsl'), )) - else if($type = 'text') - then(transform:transform($doc, concat($base, 'teiHeader2HTML.xsl'),)) - else() \ No newline at end of file + if ($type = 'work') + then + (transform:transform($doc, concat($base, 'meiHead2HTML.xsl'), )) + else + if ($type = 'source') + then + (transform:transform($doc, concat($base, 'meiHead2HTML.xsl'), )) + else + if ($type = 'recording') + then + (transform:transform($doc, concat($base, 'meiHead2HTML.xsl'), )) + else + if ($type = 'text') + then + (transform:transform($doc, concat($base, 'teiHeader2HTML.xsl'), )) + else + () \ No newline at end of file diff --git a/add/data/xql/getHelp.xql b/add/data/xql/getHelp.xql index 09dc6cbf0..0a3be7416 100644 --- a/add/data/xql/getHelp.xql +++ b/add/data/xql/getHelp.xql @@ -29,10 +29,24 @@ let $base := replace(system:get-module-load-path(), 'embedded-eXist-server', '') let $doc := doc(concat('../../help/help_', $lang, '.xml')) let $xsl := doc('../xslt/edirom_langReplacement.xsl') -let $doc := transform:transform($doc, $xsl, ) +let $doc := transform:transform($doc, $xsl, ) let $xsl := doc('../xslt/teiBody2HTML.xsl') -let $doc := transform:transform($doc, $xsl, ) +let $doc := transform:transform($doc, $xsl, ) return - transform:transform($doc, doc('../xslt/edirom_idPrefix.xsl'), ) \ No newline at end of file + transform:transform($doc, doc('../xslt/edirom_idPrefix.xsl'), ) \ No newline at end of file diff --git a/add/data/xql/getInternalIdType.xql b/add/data/xql/getInternalIdType.xql index 43cd7314b..e3312e50f 100644 --- a/add/data/xql/getInternalIdType.xql +++ b/add/data/xql/getInternalIdType.xql @@ -20,44 +20,62 @@ xquery version "1.0"; ID: $Id: getInternalIdType.xql 1289 2012-03-26 13:11:43Z daniel $ :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; import module namespace functx = "http://www.functx.com"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; let $uri := request:get-parameter('uri', '') -let $docUri := if(contains($uri, '#')) then(substring-before($uri, '#')) else($uri) -let $internalId := if(contains($uri, '#')) then(substring-after($uri, '#')) else() -let $internalId := if(contains($internalId, '?')) then(substring-before($internalId, '?')) else($internalId) +let $docUri := if (contains($uri, '#')) then + (substring-before($uri, '#')) +else + ($uri) +let $internalId := if (contains($uri, '#')) then + (substring-after($uri, '#')) +else + () +let $internalId := if (contains($internalId, '?')) then + (substring-before($internalId, '?')) +else + ($internalId) let $doc := doc($docUri) let $internal := $doc/id($internalId) (: Specific handling of virtual measure IDs for parts in OPERA project :) -let $internal := if(exists($internal))then($internal)else( - if(starts-with($internalId, 'measure_') and $doc//mei:parts) - then( - let $mdivId := functx:substring-before-last(substring-after($internalId, 'measure_'), '_') - let $measureN := functx:substring-after-last($internalId, '_') - return - ( - if ( - $doc/id($mdivId)//mei:measure/@label - ) - then ( - $doc/id($mdivId)//mei:measure[@label eq $measureN][1] - ) - else ( - $doc/id($mdivId)//mei:measure[@n eq $measureN][1] - ) - ) - ) - else($internal) - ) +let $internal := if (exists($internal)) then + ($internal) +else + ( + if (starts-with($internalId, 'measure_') and $doc//mei:parts) + then + ( + let $mdivId := functx:substring-before-last(substring-after($internalId, 'measure_'), '_') + let $measureN := functx:substring-after-last($internalId, '_') + return + ( + if ( + $doc/id($mdivId)//mei:measure/@label + ) + then + ( + $doc/id($mdivId)//mei:measure[@label eq $measureN][1] + ) + else + ( + $doc/id($mdivId)//mei:measure[@n eq $measureN][1] + ) + ) + ) + else + ($internal) + ) return - if(exists($internal)) - then(local-name($internal)) - else('unknown') + if (exists($internal)) + then + (local-name($internal)) + else + ('unknown') diff --git a/add/data/xql/getLanguageFile.xql b/add/data/xql/getLanguageFile.xql index 714338f79..1da32f4e7 100644 --- a/add/data/xql/getLanguageFile.xql +++ b/add/data/xql/getLanguageFile.xql @@ -26,9 +26,9 @@ xquery version "1.0"; @author Daniel Röwenstrunk :) -declare namespace request="http://exist-db.org/xquery/request"; +declare namespace request = "http://exist-db.org/xquery/request"; -import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; +import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm"; declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; @@ -43,24 +43,25 @@ let $file := doc(concat('../locale/edirom-lang-', $lang, '.xml')) let $projectFile := doc(edition:getLanguageFileURI($edition, $lang)) return - if($mode = 'json') - then( + if ($mode = 'json') + then + ( concat('{', 'lang: "', $file/langFile/lang/text(), '",', 'version: "', $file/langFile/version/text(), '",', - 'keys: {', - string-join(( - for $entry in $file//entry - return - concat('"', $entry/string(@key), '":"', $entry/string(@value), '"') - - , - for $entry in $projectFile//entry - return - concat('"', $entry/string(@key), '":"', $entry/string(@value), '"') - ), ','), + 'keys: {', + string-join(( + for $entry in $file//entry + return + concat('"', $entry/string(@key), '":"', $entry/string(@value), '"') + + , + for $entry in $projectFile//entry + return + concat('"', $entry/string(@key), '":"', $entry/string(@value), '"') + ), ','), '}', '}') - ) - else($file) - \ No newline at end of file + ) + else + ($file) diff --git a/add/data/xql/getMeasure.xql b/add/data/xql/getMeasure.xql index 99e592b6f..f3fe68543 100644 --- a/add/data/xql/getMeasure.xql +++ b/add/data/xql/getMeasure.xql @@ -20,11 +20,11 @@ xquery version "1.0"; ID: $Id: getMeasurePage.xql 1254 2012-02-01 14:07:25Z daniel $ :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; import module namespace functx = "http://www.functx.com"; @@ -32,22 +32,30 @@ declare option exist:serialize "method=text media-type=text/plain omit-xml-decla let $id := request:get-parameter('id', '') let $measureId := request:get-parameter('measureId', '') -let $measureCount := if(contains($measureId, 'tstamp2='))then(number(substring-before(substring-after($measureId, 'tstamp2='), 'm')) + 1)else(1) -let $measureId := if(contains($measureId, '?'))then(substring-before($measureId, '?'))else($measureId) +let $measureCount := if (contains($measureId, 'tstamp2=')) then + (number(substring-before(substring-after($measureId, 'tstamp2='), 'm')) + 1) +else + (1) +let $measureId := if (contains($measureId, '?')) then + (substring-before($measureId, '?')) +else + ($measureId) let $mei := doc($id)/root() let $movementId := $mei/id($measureId)/ancestor::mei:mdiv[1]/@xml:id (: Specific handling of virtual measure IDs for parts in OPERA project :) -let $movementId := if(starts-with($measureId, 'measure_') and $mei//mei:parts) - then( - functx:substring-before-last(substring-after($measureId, 'measure_'), '_') - ) - else($movementId) +let $movementId := if (starts-with($measureId, 'measure_') and $mei//mei:parts) +then + ( + functx:substring-before-last(substring-after($measureId, 'measure_'), '_') + ) +else + ($movementId) return concat('{', - 'measureId:"', $measureId, '",', - 'movementId:"', $movementId, '",', - 'measureCount:"', $measureCount, '"', + 'measureId:"', $measureId, '",', + 'movementId:"', $movementId, '",', + 'measureCount:"', $measureCount, '"', '}') \ No newline at end of file diff --git a/add/data/xql/getMeasurePage.xql b/add/data/xql/getMeasurePage.xql index a20ce63ce..5ee226754 100644 --- a/add/data/xql/getMeasurePage.xql +++ b/add/data/xql/getMeasurePage.xql @@ -20,22 +20,24 @@ xquery version "1.0"; ID: $Id: getMeasurePage.xql 1254 2012-02-01 14:07:25Z daniel $ :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; declare function local:findMeasure($mei, $movementId, $measureIdName) { let $m := $mei/id($measureIdName) return - if($m) - then($m) - else( + if ($m) + then + ($m) + else + ( ($mei/id($movementId)//mei:measure[@n eq $measureIdName])[1] - ) + ) }; declare function local:getMeasure($mei, $measure, $movementId) as xs:string { @@ -44,22 +46,22 @@ declare function local:getMeasure($mei, $measure, $movementId) as xs:string { let $zoneId := substring-after($measure/string(@facs), '#') let $zone := $mei/id($zoneId) let $surface := $zone/parent::mei:surface - let $graphic := $surface/mei:graphic[@type='facsimile'] + let $graphic := $surface/mei:graphic[@type = 'facsimile'] return - + concat('{', - 'measureId:"', $measureId, '",', - 'zoneId:"', $zoneId, '",', - 'pageId:"', $surface/string(@xml:id), '", ', - 'movementId:"', $movementId, '",', - 'path: "', $graphic/string(@target), '", ', - 'width: "', $graphic/string(@width), '", ', - 'height: "', $graphic/string(@height), '", ', - 'ulx: "', $zone/string(@ulx), '", ', - 'uly: "', $zone/string(@uly), '", ', - 'lrx: "', $zone/string(@lrx), '", ', - 'lry: "', $zone/string(@lry), '"', + 'measureId:"', $measureId, '",', + 'zoneId:"', $zoneId, '",', + 'pageId:"', $surface/string(@xml:id), '", ', + 'movementId:"', $movementId, '",', + 'path: "', $graphic/string(@target), '", ', + 'width: "', $graphic/string(@width), '", ', + 'height: "', $graphic/string(@height), '", ', + 'ulx: "', $zone/string(@ulx), '", ', + 'uly: "', $zone/string(@uly), '", ', + 'lrx: "', $zone/string(@lrx), '", ', + 'lry: "', $zone/string(@lry), '"', '}') }; @@ -72,19 +74,27 @@ let $mei := doc($id)/root() let $measure := local:findMeasure($mei, $movementId, $measureIdName) let $extraMeasures := for $i in (2 to xs:integer($measureCount)) - let $m := $measure/following-sibling::mei:measure[$i - 1] (: TODO: following-sibling könnte problematisch sein, da so section-Grenzen nicht überwunden werden :) - return - if($m)then($m)else() - -(: Extra measure parts :) +let $m := $measure/following-sibling::mei:measure[$i - 1] (: TODO: following-sibling könnte problematisch sein, da so section-Grenzen nicht überwunden werden :) +return + if ($m) then + ($m) + else + () + + (: Extra measure parts :) let $extraMeasuresParts := for $exm in $measure | $extraMeasures - return $exm/following-sibling::mei:measure[(exists(@label) and @label = $exm/@label) or (not(exists(@label)) and @n = $exm/@n)] +return + $exm/following-sibling::mei:measure[(exists(@label) and @label = $exm/@label) or (not(exists(@label)) and @n = $exm/@n)] return concat('[', - string-join(( - local:getMeasure($mei, $measure, $movementId), - for $m in $extraMeasures return local:getMeasure($mei, $m, $movementId), - for $m in $extraMeasuresParts return local:getMeasure($mei, $m, $movementId) - ), ','), + string-join(( + local:getMeasure($mei, $measure, $movementId), + for $m in $extraMeasures + return + local:getMeasure($mei, $m, $movementId), + for $m in $extraMeasuresParts + return + local:getMeasure($mei, $m, $movementId) + ), ','), ']') \ No newline at end of file diff --git a/add/data/xql/getMeasures.xql b/add/data/xql/getMeasures.xql index ce0af33b3..fb8b88a03 100644 --- a/add/data/xql/getMeasures.xql +++ b/add/data/xql/getMeasures.xql @@ -19,98 +19,110 @@ xquery version "3.1"; :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; -import module namespace functx="http://www.functx.com"; +import module namespace functx = "http://www.functx.com"; import module namespace eutil = "http://www.edirom.de/xquery/util" at "/db/apps/Edirom-Online/data/xqm/util.xqm"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; declare function local:getMeasures($mei as node(), $mdivID as xs:string) as xs:string* { - if($mei//mei:parts) - then( + if ($mei//mei:parts) + then + ( let $mdiv := $mei/id($mdivID) let $measureNs := if ($mdiv//mei:measure/@label) - then ( - let $labels := $mdiv//mei:measure/@label/string() - for $label in $labels - let $labelsAnalyzed := if (contains($label, '–')) - then ((:substring-before($label, '–'):) - let $first := substring-before($label, '–') - let $last := substring-after($label, '–') - let $steps := xs:integer(number($last) - number($first) + number(1)) - for $i in 1 to $steps - return - string(number($first) + $i - 1) - ) - else ($label) - return - $labelsAnalyzed - ) - else ($mdiv//mei:measure/@n) + then + ( + let $labels := $mdiv//mei:measure/@label/string() + for $label in $labels + let $labelsAnalyzed := if (contains($label, '–')) + then + ((:substring-before($label, '–'):) + let $first := substring-before($label, '–') + let $last := substring-after($label, '–') + let $steps := xs:integer(number($last) - number($first) + number(1)) + for $i in 1 to $steps + return + string(number($first) + $i - 1) + ) + else + ($label) + return + $labelsAnalyzed + ) + else + ($mdiv//mei:measure/@n) let $measureNsDistinct := distinct-values(eutil:sort-as-numeric-alpha($measureNs)) return for $measureN in $measureNsDistinct let $measureNNumber := number($measureN) let $measures := if ($mdiv//mei:measure/@label) - then ($mdiv//mei:measure[.//mei:multiRest][number(substring-before(@label, '–')) <= $measureNNumber][.//mei:multiRest/number(@num) gt ($measureNNumber - number(substring-before(@label, '–')))]) - else ($mdiv//mei:measure[.//mei:multiRest][number(@n) lt $measureNNumber][.//mei:multiRest/number(@num) gt ($measureNNumber - number(@n))]) + then + ($mdiv//mei:measure[.//mei:multiRest][number(substring-before(@label, '–')) <= $measureNNumber][.//mei:multiRest/number(@num) gt ($measureNNumber - number(substring-before(@label, '–')))]) + else + ($mdiv//mei:measure[.//mei:multiRest][number(@n) lt $measureNNumber][.//mei:multiRest/number(@num) gt ($measureNNumber - number(@n))]) let $measures := for $part in $mdiv//mei:part - let $partMeasures := if($part//mei:measure/@label) - then($part//mei:measure[@label = $measureN][1]) - else($part//mei:measure[@n = $measureN][1]) - for $measure in $partMeasures | $measures[ancestor::mei:part = $part] - let $voiceRef := $part//mei:staffDef/@decls - return - concat('{id:"', $measure/@xml:id, '", + let $partMeasures := if ($part//mei:measure/@label) + then + ($part//mei:measure[@label = $measureN][1]) + else + ($part//mei:measure[@n = $measureN][1]) + for $measure in $partMeasures | $measures[ancestor::mei:part = $part] + let $voiceRef := $part//mei:staffDef/@decls + return + concat('{id:"', $measure/@xml:id, '", voice: "', $voiceRef, - '", partLabel: "', eutil:getPartLabel($measure, 'measure'), - '"}') + '", partLabel: "', eutil:getPartLabel($measure, 'measure'), + '"}') return concat('{', - 'id: "measure_', $mdiv/@xml:id, '_', $measureN, '", ', - 'measures: [', string-join($measures, ','), '], ', - 'mdivs: ["', $mdiv/@xml:id, '"], ', (: TODO :) - 'name: "', $measureN, '"', + 'id: "measure_', $mdiv/@xml:id, '_', $measureN, '", ', + 'measures: [', string-join($measures, ','), '], ', + 'mdivs: ["', $mdiv/@xml:id, '"], ', (: TODO :) + 'name: "', $measureN, '"', '}') - ) - - else( - - if($mei/id($mdivID)//mei:measure[@label]) - then( - for $measureN in $mei/id($mdivID)//mei:measure/@label - let $measures := $mei/id($mdivID)//mei:measure[@label = $measureN] - let $measure := $measures[1] - (:let $measureLabel := if(exists($measure/@label) and not(contains($measure/@label,'/'))) then($measure/@label) else($measure/@n):) - return - concat('{', - 'id: "', $measure/@xml:id, '", ', - 'measures: [{id:"', $measure/@xml:id, '", voice: "score"}], ', - 'mdivs: ["', $measure/ancestor::mei:mdiv[1]/@xml:id, '"], ', (: TODO :) - 'name: "', $measureN, '"', (: Hier Unterscheiden wg. Auftakt. :) - '}') ) - else( + else + ( + + if ($mei/id($mdivID)//mei:measure[@label]) + then + ( + for $measureN in $mei/id($mdivID)//mei:measure/@label + let $measures := $mei/id($mdivID)//mei:measure[@label = $measureN] + let $measure := $measures[1] + (:let $measureLabel := if(exists($measure/@label) and not(contains($measure/@label,'/'))) then($measure/@label) else($measure/@n):) + return + concat('{', + 'id: "', $measure/@xml:id, '", ', + 'measures: [{id:"', $measure/@xml:id, '", voice: "score"}], ', + 'mdivs: ["', $measure/ancestor::mei:mdiv[1]/@xml:id, '"], ', (: TODO :) + 'name: "', $measureN, '"', (: Hier Unterscheiden wg. Auftakt. :) + '}') + ) + else + ( + for $measureN in $mei/id($mdivID)//mei:measure/data(@n) - let $measures := $mei/id($mdivID)//mei:measure[@n = $measureN] - let $measure := $measures[1] - (:let $measureLabel := if(exists($measure/@label) and not(contains($measure/@label,'/'))) then($measure/@label) else($measure/@n):) - return - concat('{', - 'id: "', $measure/@xml:id, '", ', - 'measures: [{id:"', $measure/@xml:id, '", voice: "score"}], ', - 'mdivs: ["', $measure/ancestor::mei:mdiv[1]/@xml:id, '"], ', (: TODO :) - 'name: "', $measureN, '"', (: Hier Unterscheiden wg. Auftakt. :) - '}') + let $measures := $mei/id($mdivID)//mei:measure[@n = $measureN] + let $measure := $measures[1] + (:let $measureLabel := if(exists($measure/@label) and not(contains($measure/@label,'/'))) then($measure/@label) else($measure/@n):) + return + concat('{', + 'id: "', $measure/@xml:id, '", ', + 'measures: [{id:"', $measure/@xml:id, '", voice: "score"}], ', + 'mdivs: ["', $measure/ancestor::mei:mdiv[1]/@xml:id, '"], ', (: TODO :) + 'name: "', $measureN, '"', (: Hier Unterscheiden wg. Auftakt. :) + '}') + ) ) - ) }; let $uri := request:get-parameter('uri', '') @@ -119,4 +131,5 @@ let $mei := doc($uri)/root() let $ret := local:getMeasures($mei, $mdivID) -return concat('[', string-join($ret, ','), ']') \ No newline at end of file +return + concat('[', string-join($ret, ','), ']') \ No newline at end of file diff --git a/add/data/xql/getMeasuresOnPage.xql b/add/data/xql/getMeasuresOnPage.xql index 4be580089..985dffb07 100644 --- a/add/data/xql/getMeasuresOnPage.xql +++ b/add/data/xql/getMeasuresOnPage.xql @@ -26,11 +26,11 @@ xquery version "3.1"; @author Daniel Röwenstrunk :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; -declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; +declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "json"; declare option output:media-type "application/json"; @@ -43,8 +43,8 @@ declare option output:media-type "application/json"; @returns A list of json objects with measure information :) declare function local:getMeasures($mei as node(), $surface as node()) as map(*)* { - - for $zone in $surface/mei:zone[@type='measure'] + + for $zone in $surface/mei:zone[@type = 'measure'] let $zoneRef := concat('#', $zone/@xml:id) (: The first predicate with `contains` is just a rough estimate to narrow down the result set. @@ -53,10 +53,15 @@ declare function local:getMeasures($mei as node(), $surface as node()) as map(*) let $measures := $mei//mei:measure[contains(@facs, $zoneRef)][$zoneRef = tokenize(@facs, '\s+')] return for $measure in $measures - let $measureLabel := if ($measure/@label) then ($measure/string(@label)) else ($measure/string(@n)) - let $measureLabel := if($measure//mei:multiRest) - then ($measureLabel || '–' || number($measureLabel) + number($measure//mei:multiRest/@num) - 1) - else ($measureLabel) + let $measureLabel := if ($measure/@label) then + ($measure/string(@label)) + else + ($measure/string(@n)) + let $measureLabel := if ($measure//mei:multiRest) + then + ($measureLabel || '–' || number($measureLabel) + number($measure//mei:multiRest/@num) - 1) + else + ($measureLabel) return map { 'zoneId': $zone/string(@xml:id), @@ -72,11 +77,15 @@ declare function local:getMeasures($mei as node(), $surface as node()) as map(*) }; declare function local:getMRest($measure) { - if($measure//mei:mRest) - then(string('1')) - else if($measure//mei:multiRest) - then($measure//mei:multiRest/string(@num)) - else(string('0')) + if ($measure//mei:mRest) + then + (string('1')) + else + if ($measure//mei:multiRest) + then + ($measure//mei:multiRest/string(@num)) + else + (string('0')) }; let $uri := request:get-parameter('uri', '') @@ -85,9 +94,10 @@ let $surfaceId := request:get-parameter('pageId', '') let $mei := doc($uri)/root() let $surface := $mei/id($surfaceId) -return ( +return + ( array { (: TODO: überlegen, wie die Staff-spezifischen Ausschnitte angezeigt werden sollen :) local:getMeasures($mei, $surface) } -) \ No newline at end of file + ) \ No newline at end of file diff --git a/add/data/xql/getMovements.xql b/add/data/xql/getMovements.xql index f361c74d0..ff6490e35 100644 --- a/add/data/xql/getMovements.xql +++ b/add/data/xql/getMovements.xql @@ -20,11 +20,11 @@ xquery version "3.1"; ID: $Id: getMovements.xql 1219 2012-01-20 08:33:28Z daniel $ :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare option output:method "text"; @@ -34,17 +34,18 @@ let $uri := request:get-parameter('uri', '') let $mei := doc($uri)/root() let $ret := for $movement in $mei//mei:mdiv - return - map { - 'id': $movement/string(@xml:id), - 'name': $movement/string(@label) - } - -let $array := array { $ret } -let $options := +return map { - 'method': 'json', - 'media-type': 'text/plain' + 'id': $movement/string(@xml:id), + 'name': $movement/string(@label) } - -return serialize($array, $options) \ No newline at end of file + +let $array := array {$ret} +let $options := +map { + 'method': 'json', + 'media-type': 'text/plain' +} + +return + serialize($array, $options) \ No newline at end of file diff --git a/add/data/xql/getMovementsFirstPage.xql b/add/data/xql/getMovementsFirstPage.xql index 388e48d64..68faa335a 100644 --- a/add/data/xql/getMovementsFirstPage.xql +++ b/add/data/xql/getMovementsFirstPage.xql @@ -20,11 +20,11 @@ xquery version "1.0"; ID: $Id: getMovementsFirstPage.xql 1261 2012-02-28 15:50:45Z daniel $ :) -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes"; @@ -34,8 +34,11 @@ let $movementId := request:get-parameter('movementId', '') let $mei := doc($uri)/root() let $zoneId := ($mei/id($movementId)//mei:measure)[1]/string(@facs) -let $zoneId := if(starts-with($zoneId, '#')) - then(substring($zoneId, 2)) - else($zoneId) - -return $mei/id($zoneId)/parent::mei:surface/string(@xml:id) \ No newline at end of file +let $zoneId := if (starts-with($zoneId, '#')) +then + (substring($zoneId, 2)) +else + ($zoneId) + +return + $mei/id($zoneId)/parent::mei:surface/string(@xml:id) \ No newline at end of file diff --git a/add/data/xql/getMusicInMdiv.xql b/add/data/xql/getMusicInMdiv.xql index d120f8b2b..0b675c7a1 100644 --- a/add/data/xql/getMusicInMdiv.xql +++ b/add/data/xql/getMusicInMdiv.xql @@ -1,23 +1,28 @@ xquery version "3.0"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace mei="http://www.music-encoding.org/ns/mei"; -declare namespace system="http://exist-db.org/xquery/system"; -declare namespace transform="http://exist-db.org/xquery/transform"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace mei = "http://www.music-encoding.org/ns/mei"; +declare namespace system = "http://exist-db.org/xquery/system"; +declare namespace transform = "http://exist-db.org/xquery/transform"; let $uri := request:get-parameter('uri', '') let $movementId := request:get-parameter('movementId', '') let $mei := doc($uri)/root() -let $mdiv := if($movementId eq '') - then($mei//mei:mdiv[1]) - else($mei/id($movementId)) - +let $mdiv := if ($movementId eq '') +then + ($mei//mei:mdiv[1]) +else + ($mei/id($movementId)) + let $base := concat(replace(system:get-module-load-path(), 'embedded-eXist-server', ''), '/../xslt/') let $data := transform:transform($mdiv, concat($base, 'edirom_prepareAnnotsForRendering.xsl'), ) return - + {$mei//mei:meiHead} diff --git a/add/data/xql/getNavigatorConfig.xql b/add/data/xql/getNavigatorConfig.xql index 1cfbcd69d..e370087c8 100644 --- a/add/data/xql/getNavigatorConfig.xql +++ b/add/data/xql/getNavigatorConfig.xql @@ -20,91 +20,140 @@ xquery version "1.0"; ID: $Id: getNavigatorConfig.xql 1279 2012-03-19 13:16:43Z daniel $ :) -import module namespace eutil="http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; +import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm"; -declare namespace request="http://exist-db.org/xquery/request"; -declare namespace edirom="http://www.edirom.de/ns/1.3"; -declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace edirom = "http://www.edirom.de/ns/1.3"; +declare namespace xlink = "http://www.w3.org/1999/xlink"; -declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes"; declare variable $lang := request:get-parameter('lang', ''); declare function local:getCategory($category, $depth) { - -