diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml
index 92c23a9b0..93c31191a 100644
--- a/.github/workflows/docker-ci.yml
+++ b/.github/workflows/docker-ci.yml
@@ -7,6 +7,9 @@ on:
types: [ opened, synchronize, reopened ]
branches: [ develop, main ]
+permissions:
+ contents: read
+
env:
DOCKER_IMAGE: bwbohl/sencha-cmd
@@ -18,10 +21,10 @@ jobs:
steps:
- name: Chekout repository
- uses: actions/checkout@v4
+ uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get short sha
- uses: benjlevesque/short-sha@v2.2
+ uses: benjlevesque/short-sha@599815c8ee942a9616c92bcfb4f947a3b670ab0b # v3.0
id: short-sha
with:
length: 7
@@ -31,7 +34,7 @@ jobs:
- name: Upload Artifacts to action run
if: github.repository == 'Edirom/Edirom-Online'
- uses: actions/upload-artifact@v3.1.3
+ uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
# The name that the artifact will be made available under
name: EdiromOnline_${{ steps.short-sha.outputs.sha }}.zip
diff --git a/.gitignore b/.gitignore
index ef633cde5..9a8b2e120 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,5 @@ Thumbs.db
*.xpr
local.properties
.idea/
+.existdb.json
+.vscode/settings.json
diff --git a/.gitmodules b/.gitmodules
index afe8f047f..d9e177c17 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,7 @@
[submodule "packages/eoTheme/resources/fonts/euryanthe"]
path = packages/eoTheme/resources/fonts/euryanthe
url = https://github.com/Edirom/EuryantheFont
+[submodule "Stylesheets"]
+ path = add/data/xslt/tei/Stylesheets
+ url = https://github.com/TEIC/Stylesheets
+ branch = released
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 80e39c2f8..e07179ce3 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,50 +9,200 @@
1. Use whitespaces, not tabs to indent code
2. Close file with a newline character
+# XQuery Styleguide
-# XQuery
+For formatting of XQuery files we generally rely on the basic configuration of Synchrosoft’s oXygen XML software family and its “Format & Indent” function.
## xqDoc
-We use [xqDoc](https://xqdoc.org) for documenting the XQueries in this repository. Please refer to the section [xqDoc Comments](https://xqdoc.org/xqdoc_comments_doc.html) of the xyDoc-website for details on formatting the documentation comment blocks.
+We use [xqDoc](https://xqdoc.org) for documenting the XQueries in this repository. Please refer to the section [xqDoc Comments](https://xqdoc.org/xqdoc_comments_doc.html) of the xqDoc-website for details on formatting the documentation comment blocks.
* XQuery modules must have a library module xqDoc comment preceding the module declaration.
* Function declarations must have a library module xqDoc function comment preceding the function.
## XQuery document structure
-### XQuery version
+### XQuery version declaration
```xquery
xquery version 3.1;
```
-### License Statement
+### Beginning comments
+
+For now, the beginning comments should only include the following:
```xquery
(:
-For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
-:)
+ : Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
+
+ ```
+The beginning comments and the structuring comments (see below) of the prolog are separated by a blank line.
+
+### Prolog
+
+1. The parts of the prolog, are introduced by a comment followed by a new line.
+2. The below form of the comments and the order of the parts is prescriptive.
+3. Each part of the prolog ends with a blank line.
+
+```xquery
+(: IMPORTS ================================================================= :)
+
+```
+
+Sort imports by type:
+1. All `import module namespace` statements registered with eXist-db
+2. All `import module namespace` statements of custom modules that are not registered with eXist-db. Always use relative URIs for unregistered `import module namespace` statements.
+3. Separate groups with a blank line.
+4. In the groups sort alphabetically by prefix.
+
+```xquery
+(: NAMESPACE DECLARATIONS ================================================== :)
+
```
-### File Header
+All `declare namespace` statements, sorted alphabetically by prefix.
+
+```xquery
+(: OPTION DECLARATIONS ===================================================== :)
-1. `declare namespace` statements
- * sort alphabetically by prefix
-2. `import module namespace` statements of registered modules
- * sort alphabetically by prefix
-3. `import module namespace` statements of custom modules
- * sort alphabetically by prefix
- * Always use relative URIs for `import module namespace` statements that import for modules not registered with eXist-db.
-### Declare variables
+```
+All `declare option` statements.
-* Use `declare variable` statements for all required external parameters
+```xquery
+(: VARIABLE DECLARATIONS =================================================== :)
+
+```
+1. Use `declare variable` statements for all required external parameters
+2. All global variable declarations, i.e. `declare variable` statements.
+3. Separate these two groups with a blank line.
+4. In the groups, sort alphabetically.
+
+```xquery
+(: FUNCTION DECLARATIONS =================================================== :)
+
+```
+
+1. All `declare function` statements.
+2. All function declarations have to be preceded by an xqDoc comment.
+3. The xqDoc comment and function declaration belonging together are not separated by blank lines – not even one ;-)
+4. The comment-function-groups are separated by blank lines.
+
+A prototypical example:
+
+```xquery
+(: FUNCTION DECLARATIONS =========================================== :)
+
+(:~
+ :
+ :)
+declare function eg:addComment($comment as xs:string, $function as function())
+as xs:string
+{
+ …
+}
+
+(:~
+ :)
+declare function eg:addComment($comment as xs:string, $function as function())
+as xs:string
+{
+ …
+}
+```
+
+### Query body
+
+The Query body start after a structuring comment as follows:
+
+```xquery
+(: QUERY BODY ============================================================== :)
+
+```
+
+#### Strings
+
+Note: this is derived from the current usage in Edirom-Online code
+
+* escape with U+00027 APOSTROPHE: `'`
+
+### Literal results
+
+TODO: how should literal results be indented, especially when they are long, e.g., as in the case of [getAudioPlayer.xql](add/data/xql/getAudioPlayer.xql).
+
+### let statements
+
+Short variable definitions should be in a single line:
+
+```xquery
+let $lang := 'de'
+```
+
+Longer assignments, especially when the contain if-else-statements or FLWOR-expressions, should break after `:=` and then indent a further level, before following the rules applicable to the respective statements, e.g.:
+
+```xquery
+let $elems :=
+ for $p in $participants
+ let $id := substring-after($p, '#')
+ return doc($doc)/id($id)
+```
### Function declarations
-* functions have to be preceded by an xqDoc comment
+```xquery
+(:~
+ : XQdoc comment
+ :
+ …
+ :
+ :)
+declare function prefix:function-name( $paramOne as datatype, §paramTwo as datatype )
+as datatype
+{
+ …
+};
+
+```
+
+- [ ] at the moment return datatypes and opening curly braces of function declarations are still in the same line as the `declare function` statement
+- [ ] break long function argument
+
+### HowTo ToDo:s
+
+- [ ] literal results formatting
+- [ ] nested return statements
+- [ ] parenthesis placement
+
-### XQuery body
+# Javascript
+
+## AJAX calls
+
+The class `EdiromOnline.controller.AJAXController` provides a central method `doAJAXRequest` for performing AJAX requests. The method is provided globally as `window.doAJAXRequest`.
+
+`doAJAXRequest` takes the following arguments:
+
+* `url`: The URL of the requestet site or end point.
+* `method`: The HTTP method like `PUT`, `GET`, `POST`.
+* `params`: An object containing key-value-pairs of parameters for the request.
+* `successFn`: A callback function which is called when the AJAX request was successfull.
+* `retryNo`: The number of retries, if the requests fails. Standard is 2 retries.
+* `async`: Defines the async parameter for AJAX calls. Default is 'true'.
+
+An example of using the function would be:
+
+```javascript
+window.doAJAXRequest('data/xql/getAnnotationMeta.xql',
+ 'GET',
+ {
+ uri: uri,
+ lang: lang
+ },
+ Ext.bind(function(response){
+ view.setMeta(response.responseText);
+ }, this)
+);
+```
-* Strings: escape with U+00027 APOSTROPHE: `'`
\ No newline at end of file
diff --git a/add/data/xql/checkTextGridLogin.xql b/add/data/xql/checkTextGridLogin.xql
index 3d154e3f5..3352e9dae 100644
--- a/add/data/xql/checkTextGridLogin.xql
+++ b/add/data/xql/checkTextGridLogin.xql
@@ -1,15 +1,22 @@
-xquery version "3.0";
+xquery version "3.1";
-declare namespace html="http://www.w3.org/1999/xhtml";
-declare namespace h="http://exist-db.org/xquery/httpclient";
+(:
+ : Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
-let $sessionId := request:get-parameter('sessionId', '')
+(: IMPORTS ================================================================= :)
+
+import module namespace httpclient = "http://exist-db.org/xquery/httpclient";
+
+(: NAMESPACE DECLARATIONS ================================================== :)
-let $test := httpclient:head(xs:anyURI('http://textgridlab.org/1.0/tgcrud/rest/textgrid:208dw/data?sessionId=' || $sessionId),
- false(), ())
+declare namespace html = "http://www.w3.org/1999/xhtml";
+(: QUERY BODY ============================================================== :)
+
+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(), ())
let $status := $test/root()/httpclient:response/string(@statusCode)
let $status := response:set-status-code(xs:int($status))
-
return
- $status
\ No newline at end of file
+ $status
diff --git a/add/data/xql/edirom_printPreview.xql b/add/data/xql/edirom_printPreview.xql
index 6762ed4c7..fce9e961e 100644
--- a/add/data/xql/edirom_printPreview.xql
+++ b/add/data/xql/edirom_printPreview.xql
@@ -1,114 +1,161 @@
-xquery version "1.0";
+xquery version "3.1";
-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";
+(:
+ : Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
-declare namespace request="http://exist-db.org/xquery/request";
-declare namespace xslfo="http://exist-db.org/xquery/xslfo";
+(: IMPORTS ================================================================= :)
+
+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";
+
+(: NAMESPACE DECLARATIONS ================================================== :)
-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 fo = "http://www.w3.org/1999/XSL/Format";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace xhtml = "http://www.w3.org/1999/xhtml";
+declare namespace xslfo = "http://exist-db.org/xquery/xslfo";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=html media-type=text/html omit-xml-declaration=yes indent=yes";
-(: VARIABLES ========================================================= :)
+(: VARIABLE DECLARATIONS =================================================== :)
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')
+(: FUNCTION DECLARATIONS =================================================== :)
+
+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..4e2de75ce 100644
--- a/add/data/xql/getAnnotation.xql
+++ b/add/data/xql/getAnnotation.xql
@@ -1,158 +1,152 @@
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.
+(:
+ : Copyright: 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.
+(: IMPORTS ================================================================= :)
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
+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 eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
+import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm";
- ID: $Id: getAnnotation.xql 1455 2012-10-11 10:42:55Z daniel $
-:)
+(: NAMESPACE DECLARATIONS ================================================== :)
-(:~
- Returns the HTML for a specific annotation for an AnnotationView.
-
- @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";
-
-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 edirom_image = "http://www.edirom.de/ns/image";
+declare namespace exist = "http://exist.sourceforge.net/NS/exist";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
-declare option output:method "xhtml";
declare option output:media-type "text/html";
+declare option output:method "xhtml";
+
+(: VARIABLE DECLARATIONS =================================================== :)
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', '');
+(: FUNCTION DECLARATIONS =================================================== :)
+
(: TODO: in Modul auslagern :)
(:~
- Gets the zone holding the graphical representation of an element
-
- @param $elem The element for which the graphical representation shall be found
-
- @return The zone element
-:)
+ : Gets the zone holding the graphical representation of an element
+ :
+ : @param $elem The element for which the graphical representation shall be found
+ : @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(
- $elem
- )
+ return
+ $elem/root()/id($zoneId)
+ ) else
+ ($elem)
};
(:~
- This function gets the label of a given Annotation Priority
-
- @param $annot the annot with a priority to look for
-
- @return the label for the Priority, or, if this fails, $uri
-:)
+ : This function gets the label of a given Annotation Priority
+ :
+ : @param $annot the annot with a priority to look for
+ : @return the label for the Priority, or, if this fails, $uri
+ :)
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)
};
(:~
- This function gets a string representing all Annotation categories
-
- @param $annot the annot with categories to look for
-
- @return the string of annotation labels, or, if one of them fails, the respecitve $uri
-:)
+ : This function gets a string representing all Annotation categories
+ :
+ : @param $annot the annot with categories to look for
+ : @return the string of annotation labels, or, if one of them fails, the respecitve $uri
+ :)
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
+};
(: TODO: in Modul auslagern :)
(:~
- This function generates an image path for a specific zone on an image.
- Based on a path prefix and a width.
-
- @param $basePath The base path prefix for the image databse
- @param $zone The zone with coordiantes on the image
- @param $width The width the image should be loaded with
-
- @return A URL pointing to an image based as xs:string
-:)
+ : This function generates an image path for a specific zone on an image.
+ : Based on a path prefix and a width.
+ :
+ : @param $basePath The base path prefix for the image databse
+ : @param $zone The zone with coordiantes on the image
+ : @param $width The width the image should be loaded with
+ : @return A URL pointing to an image based as xs:string
+ :)
declare function local:getImageAreaPath($basePath as xs:string, $zone as element()?, $width as xs:integer) 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 $imagePath := $graphic/@target
let $imgWidth := number($graphic/@width)
let $imgHeight := number($graphic/@height)
-
+
let $wx := $imgX div $imgWidth
let $wy := $imgY div $imgHeight
let $ww := $w div $imgWidth
let $wh := $h div $imgHeight
-
+
return
concat($basePath, $imagePath, '?dw=', $width, '&dh=', $width, '&wx=', $wx, '&wy=', $wy, '&ww=', $ww, '&wh=', $wh, '&mo=fit')
};
@@ -160,163 +154,245 @@ declare function local:getImageAreaPath($basePath as xs:string, $zone as element
(: for tips :)
declare function local:getImageAreaPathForTips($basePath as xs:string, $zone as element()?, $width as xs:integer, $height as xs:integer) 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 $imagePath := $graphic/@target
let $imgWidth := number($graphic/@width)
let $imgHeight := number($graphic/@height)
-
+
let $wx := $imgX div $imgWidth
let $wy := $imgY div $imgHeight
let $ww := $w div $imgWidth
let $wh := $h div $imgHeight
-
+
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
};
-(:
- This function recursively determines the lowest number which's square is higher than
- a given number.
-
- @param $i The integer that's increased with every recursive call.
- @param $num The integer that's tested.
-
- @return Returns $i if it's square is higher or equals $num.
-:)
+(:~
+ : This function recursively determines the lowest number which's square is higher than
+ : a given number.
+ :
+ : @param $i The integer that's increased with every recursive call.
+ : @param $num The integer that's tested.
+ : @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(),
-
- 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 = 'measure') then (
+ if ($lang = 'de') then
+ (concat('Takt ', if ($elem/@label) then ($elem/@label) else ($elem/@n)))
+ else
+ (concat('Bar ',if ($elem/@label) then ($elem/@label) else ($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
+ (),
-(:
- This function…
+ 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
+ ()
+ )
+};
-:)
+(:~
+ : This function…
+ :
+ :)
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 $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)
- )
-
+
+ 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)
+ )
+
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)
+
let $annot := $doc/id($internalId)
let $participants := annotation:getParticipants($annot)
let $priority := local:getPriority($annot)
-let $priorityLabel := if ($lang = 'de')
- then('Priorität')
- else('Priority')
+
+let $priorityLabel :=
+ if ($lang = 'de') 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'))
+
+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'))
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'))
+
+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')
+ )
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'))
-
-let $annotIDlabel := if ($lang = 'de')
- then ('Anm.-ID')
- else ('Annot.-ID')
+
+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')
+ )
+
+let $annotIDlabel :=
+ if ($lang = 'de') then
+ ('Anm.-ID')
+ else
+ ('Annot.-ID')
return
- if($target eq 'view')
- then(
-
+ if ($target eq 'view') then (
-
- )
\ No newline at end of file
+
+ )
diff --git a/add/data/xql/getAnnotationInfos.xql b/add/data/xql/getAnnotationInfos.xql
index 4b5775baf..42759c3cd 100644
--- a/add/data/xql/getAnnotationInfos.xql
+++ b/add/data/xql/getAnnotationInfos.xql
@@ -1,18 +1,26 @@
xquery version "3.1";
(:
-For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
-:)
+ : Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
+
+(: IMPORTS ================================================================= :)
+
+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";
+
+(: NAMESPACE DECLARATIONS ================================================== :)
declare namespace mei = "http://www.music-encoding.org/ns/mei";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace request = "http://exist-db.org/xquery/request";
-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";
+(: OPTION DECLARATIONS ===================================================== :)
declare option output:method "json";
declare option output:media-type "application/json";
+(: VARIABLE DECLARATIONS =================================================== :)
+
declare variable $uri := request:get-parameter('uri', '');
declare variable $edition := request:get-parameter('edition', '');
declare variable $edition_path := eutil:getPreference('edition_path', $edition);
@@ -21,29 +29,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,52 +60,29 @@ 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
-
- (:
-
-return concat('{categories: [',
- string-join(
- for $category in local:getDistinctCategories($annots)
- let $categoryElement := (collection($edition_path)/id($category))[1]
- let $name := annotation:category_getName($categoryElement, eutil:getLanguage($edition))
- order by $name
- return
- concat('{id:"', $category, '",name:"', $name,'"}')
- , ','),
- '], priorities: [',
- string-join(
- for $priority in local:getDistinctPriorities($annots)
- let $name := eutil:getLocalizedName((collection($edition_path)//id($priority))[1], $lang)
- order by $name
- return
- concat('{id:"', $priority, '",name:"', $name,'"}')
- , ','),
- ']}')
-
- :)
\ No newline at end of file
+ $map
diff --git a/add/data/xql/getAnnotationMeta.xql b/add/data/xql/getAnnotationMeta.xql
index d181fe603..7df02a6d4 100644
--- a/add/data/xql/getAnnotationMeta.xql
+++ b/add/data/xql/getAnnotationMeta.xql
@@ -1,42 +1,33 @@
-xquery version "3.0";
-(:
- 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 .
+xquery version "3.1";
- ID: $Id: getAnnotationMeta.xql 1324 2012-05-15 13:59:35Z daniel $
-:)
+(:
+ : Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns the HTML for a specific annotation for an AnnotationView.
-
+
@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";
-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";
+(: IMPORTS ================================================================= :)
+
+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 source = "http://www.edirom.de/xquery/source" at "../xqm/source.xqm";
+
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+declare namespace edirom_image = "http://www.edirom.de/ns/image";
+declare namespace exist = "http://exist.sourceforge.net/NS/exist";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
-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";
+(: OPTION DECLARATIONS ===================================================== :)
+
declare option output:method "xhtml";
declare option output:media-type "text/html";
@@ -51,52 +42,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..47499f6b3 100644
--- a/add/data/xql/getAnnotationOpenAllUris.xql
+++ b/add/data/xql/getAnnotationOpenAllUris.xql
@@ -1,63 +1,66 @@
-xquery version "3.0";
-(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+xquery version "3.1";
- 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.
+(:
+ : Copyright: 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.
+(: IMPORTS ================================================================= :)
- You should have received a copy of the GNU General Public License
- 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";
+(: NAMESPACE DECLARATIONS ================================================== :)
-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";
+(: OPTION DECLARATIONS ===================================================== :)
+
declare option output:method "text";
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 +70,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 +104,5 @@ let $doc := doc($uri)
let $annot := $doc/id($annotId)
return
- string-join(local:getParticipants($annot),'
- ')
\ No newline at end of file
+ string-join(local:getParticipants($annot), '
+ ')
diff --git a/add/data/xql/getAnnotationParticipants.xql b/add/data/xql/getAnnotationParticipants.xql
index e3fc191fc..c67f7c35a 100644
--- a/add/data/xql/getAnnotationParticipants.xql
+++ b/add/data/xql/getAnnotationParticipants.xql
@@ -1,32 +1,22 @@
-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 .
-:)
+ : Copyright: For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns a list of participants of a specific annotation.
-
+
@author Daniel Röwenstrunk
:)
-declare namespace request="http://exist-db.org/xquery/request";
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+declare namespace request = "http://exist-db.org/xquery/request";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+(: OPTION DECLARATIONS ===================================================== :)
+
declare option output:method "text";
declare option output:media-type "text/html";
@@ -43,9 +33,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..1c6944c6d 100644
--- a/add/data/xql/getAnnotationPreviews.xql
+++ b/add/data/xql/getAnnotationPreviews.xql
@@ -1,7 +1,7 @@
xquery version "3.1";
(:
-For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns the HTML for a specific annotation for an AnnotationView.
@@ -10,49 +10,64 @@ For LICENSE-Details please refer to the LICENSE file in the root directory of th
@author Benjamin W. Bohl
:)
+(: IMPORTS ================================================================= :)
+
+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 eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
+
+(: NAMESPACE DECLARATIONS ================================================== :)
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 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 eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
+(: OPTION DECLARATIONS ===================================================== :)
declare option output:method "json";
declare option output:media-type "application/json";
+(: VARIABLE DECLARATIONS =================================================== :)
+
declare variable $lang := request:get-parameter('lang', '');
declare variable $edition := request:get-parameter('edition', '');
declare variable $imageserver := eutil:getPreference('image_server', $edition);
declare variable $uri := request:get-parameter('uri', '');
-declare variable $imageBasePath := if ($imageserver = 'leaflet')
-then
+declare variable $imageBasePath := if ($imageserver = 'leaflet') then
(eutil:getPreference('leaflet_prefix', $edition))
else
(eutil:getPreference('image_prefix', $edition));
+(: FUNCTION DECLARATIONS =================================================== :)
+
+(:~
+ : Tokenizes the value of an annotation and gets attributes of each participant
+ :
+ : @param $annot an mei:annot element
+ :
+ : @return a map{} with the attributes of all participants
+ :)
declare function local:getParticipants($annot as element()) as map(*)* {
let $participants := tokenize($annot/string(@plist), ' ')
- let $docs := distinct-values(for $p in $participants
- return
- substring-before($p, '#'))
+
+ (: get distinct document uris referenced in @plist :)
+ let $docs :=
+ distinct-values(
+ for $p in $participants
+ return substring-before($p, '#')
+ )
+
return
for $doc in $docs
- order by $doc
+ order by $doc
return
- if (source:isSource($doc))
- then
+ if (source:isSource($doc)) then
+ (: filter participants starting with matching doc uri and call getSourceParticipants :)
(local:getSourceParticipants($participants[starts-with(., $doc)], $doc))
-
- else
- if (teitext:isText($doc))
- then
- (local:getTextParticipants($participants[starts-with(., $doc)], $doc))
-
- else
- ()
+ 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(*)* {
@@ -98,9 +113,15 @@ declare function local:getTextNotePrecedingContent($elem as element()) as xs:str
else
(local:getTextNotePrecedingContent($preceding))
};
-
+(:~
+ : This function returns a map with details of annotation participants from a specific music source
+ :
+ : @param $participants a prefiltered sequence of annotation URIs pointing to $doc
+ : @param $doc a URI pointing to the MEI document
+ :)
declare function local:getSourceParticipants($participants as xs:string*, $doc as xs:string) as map(*)* {
+ (: group participants :)
let $combs := local:groupParticipants($participants, $doc)
return
@@ -109,36 +130,41 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a
let $partIndices := tokenize($comb, '-')
let $elems :=
- for $p in distinct-values($partIndices)
- let $relevant.participant := $participants[starts-with(., $doc)][number($p)]
- let $element.id := substring-after($relevant.participant, '#')
- let $elem := local:getElement($relevant.participant)
- (:return if(exists($elem)) then(local-name($elem)) else($relevant.participant):)
+ for $p in distinct-values($partIndices)
+ let $relevant.participant := $participants[starts-with(., $doc)][number($p)]
+ let $element.id := substring-after($relevant.participant, '#')
+ let $elem := local:getElement($relevant.participant)
+ (:return if(exists($elem)) then(local-name($elem)) else($relevant.participant):)
where exists($elem)
order by count($elem/preceding::*)
- return
- $elem
-
- where count($elems) gt 0
+ return
+ $elem
- let $zones := for $elem in $elems
- return
- local:getZone($elem)
+ 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))
- else
- ($zones[1]/parent::mei:surface/string(@n))
+ let $page :=
+ if ($zones[1]/parent::mei:surface/@label != '') then
+ ($zones[1]/parent::mei:surface/string(@label))
+ else
+ ($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 $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)
@@ -160,6 +186,8 @@ declare function local:getSourceParticipants($participants as xs:string*, $doc a
let $linkUri := concat('xmldb:exist://', document-uri($graphic/root()), '#', local:getSourceLinkTarget($elems, $zones))
+ where count($elems) gt 0
+
return
map {
'type': $type,
@@ -199,35 +227,33 @@ 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 $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 $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))
+ 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)
- let $contained := for $n in (1 to count($combs) - $i)
- return
- if (contains($combs[$n], $comb))
- then
- (1)
- else
- (0)
- return
- if (exists(index-of($contained, 1)))
- then
- ()
- else
- ($comb)
+ for $comb at $i in reverse($combs)
+ let $contained := for $n in (1 to count($combs) - $i)
+ return
+ if (contains($combs[$n], $comb)) then
+ (1)
+ else
+ (0)
+ return
+ if (exists(index-of($contained, 1))) then
+ ()
+ else
+ ($comb)
)
};
@@ -235,31 +261,33 @@ declare function local:getCombinations($elems as element()*, $zones as element()
let $currentZone := $zones[$i]
let $currentElem := $elems[$i]
+
return
- if (local-name($currentElem) eq 'measure' or local-name($currentElem) eq 'staff')
- then
- (
+ if (local-name($currentElem) eq 'measure' or local-name($currentElem) eq 'staff') then (
string-join((
- string($i),
- for $n in ($i + 1 to $total)
- return
- if ((local-name($elems[$n]) eq 'measure' or local-name($elems[$n]) eq 'staff') and local:compareZones($currentZone, $zones[$n]))
- then
- (local:getCombinations($elems, $zones, $n, $total))
- else
- ()
- ), '-')
- )
- else
- (
+ string($i),
+ for $n in ($i + 1 to $total)
+ return
+ if ((local-name($elems[$n]) eq 'measure' or local-name($elems[$n]) eq 'staff') and local:compareZones($currentZone, $zones[$n])) then
+ (local:getCombinations($elems, $zones, $n, $total))
+ else
+ ()
+ ), '-')
+ ) else (
string($i)
- )
+ )
};
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))
+ 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
$samePage and $overlapping
};
@@ -281,17 +309,13 @@ declare function local:getElement($uri as xs:string) as element()? {
@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
- (
$elem
- )
};
(:~
@@ -320,25 +344,23 @@ declare function local:getImageAreaPath($basePath as xs:string, $graphic as elem
let $imgHeight := number($graphic/@height)
let $isAbsolute := starts-with($imagePath, 'http')
- let $fields := if ($imageserver = 'leaflet') then
- (substring-before($imagePath, '.'))
- else
- ()
+ let $fields :=
+ if ($imageserver = 'leaflet') then
+ (substring-before($imagePath, '.'))
+ else
+ ()
return
- if ($isAbsolute)
- then
+ if ($isAbsolute) then
$imagePath
else
switch ($imageserver)
case 'leaflet'
- return
- concat($basePath, $fields)
+ return concat($basePath, $fields)
case 'openseadragon'
- return
- concat($basePath, translate($imagePath, '/', '!'))
- default return
- concat($basePath, $imagePath, '?')
+ return concat($basePath, translate($imagePath, '/', '!'))
+ default
+ return concat($basePath, $imagePath, '?')
};
@@ -372,76 +394,65 @@ declare function local:getImageAreaParams($zone as element()?, $imgWidth as xs:i
declare function local:getItemLabel($elems as element()*) as xs:string {
let $language := eutil:getLanguage($edition)
+
return
- string-join(
- for $type in distinct-values(for $elem in $elems
- return
- local-name($elem))
- let $items := for $elem in $elems
- return
- if (local-name($elem) eq $type) then
- ($elem)
- else
- ()
- let $itemLabelMultiRestSensitive := if ($items[1]//mei:multiRest)
- then
- ($items[1]/@n || '–' || number($items[1]/@n) + number($items[1]//mei:multiRest/@num) - 1)
- else
- ($items[1]/@n)
- return
- if (local-name($items[1]) eq 'measure')
- then
- (
- if (count($items) gt 1)
- then
- (eutil:getLanguageString('Bars_from_to', ($items[1]/@n, $items[last()]/@n), $language))
+ string-join((
+ for $type in distinct-values(
+ for $elem in $elems
+ return local-name($elem))
+
+ let $items :=
+ for $elem in $elems
+ return
+ if (local-name($elem) eq $type) then
+ $elem
+ else
+ ()
+
+ let $itemLabelMultiRestSensitive :=
+ if ($items[1]//mei:multiRest) then
+ ($items[1]/@n || '–' || number($items[1]/@n) + number($items[1]//mei:multiRest/@num) - 1)
else
- (eutil:getLanguageString('Bar_n', $itemLabelMultiRestSensitive, $language))
- )
- else
- if (local-name($items[1]) eq 'staff')
- (: TODO: $itemLabelMultiRestSensitive also for staffs? :)
- then
- (
- if (count($items) gt 1)
- then
- (
+ $items[1]/@n
+ return
+ if (local-name($items[1]) eq 'measure') then (
+ if (count($items) gt 1) then
+ (eutil:getLanguageString('Bars_from_to', ($items[1]/@n, $items[last()]/@n), $language))
+ else
+ (eutil:getLanguageString('Bar_n', $itemLabelMultiRestSensitive, $language))
+ ) else if (local-name($items[1]) eq 'staff') then (: TODO: $itemLabelMultiRestSensitive also for staffs? :) (
+ 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
- (concat('Takte ', $measureNs[1], '-', $measureNs[last()]))
- else
- (concat('Takt ', $measureNs[1])))
- else
- (if (count($measureNs) gt 1) then
- (concat('Bars ', $measureNs[1], '-', $measureNs[last()]))
- else
- (concat('Bar ', $measureNs[1])))
+ let $label :=
+ if ($lang = 'de') then(
+ if (count($measureNs) gt 1) then
+ (concat('Takte ', $measureNs[1], '-', $measureNs[last()]))
+ else (
+ concat('Takt ', $measureNs[1])
+ )
+ ) else (
+ if (count($measureNs) gt 1) then (
+ 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
+ ) else
(concat('Takt ', $items[1]/ancestor::mei:measure/@n, ' (', $items[1]/preceding::mei:staffDef[@n = $items[1]/@n][1]/@label.abbr, ')'))
+
+ ) else if (local-name($items[1]) eq 'zone') then (
+ if (count($items) gt 1) then (
+ (:Dieser Fall sollte nicht vorkommen, da freie zones nicht zusammengefasst werden dürfen:)
+ ) else (
+ concat('Ausschnitt (S. ', $items[1]/parent::mei:surface/@n, ')')
)
- else
- if (local-name($items[1]) eq 'zone')
- then
- (
- if (count($items) gt 1)
- then
- ((:Dieser Fall sollte nicht vorkommen, da freie zones nicht zusammengefasst werden dürfen:) )
- else
- (concat('Ausschnitt (S. ', $items[1]/parent::mei:surface/@n, ')'))
- )
- else
- ()
- , ' ')
+ ) else ()
+ ), ' ')
};
diff --git a/add/data/xql/getAnnotationText.xql b/add/data/xql/getAnnotationText.xql
index 2a7235350..b50e16a43 100644
--- a/add/data/xql/getAnnotationText.xql
+++ b/add/data/xql/getAnnotationText.xql
@@ -1,45 +1,37 @@
-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 .
-
- ID: $Id: getAnnotationText.xql 1324 2012-05-15 13:59:35Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns the HTML for the textual content of a specific annotation for an AnnotationView.
-
+
@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";
-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";
+(: IMPORTS ================================================================= :)
+
+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";
+
+(: NAMESPACE DECLARATIONS ================================================== :)
-declare namespace xmldb="http://exist-db.org/xquery/xmldb";
+declare namespace edirom_image = "http://www.edirom.de/ns/image";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option output:method "xhtml";
declare option output:media-type "text/html";
+(: VARIABLE DECLARATIONS =================================================== :)
+
declare variable $lang := request:get-parameter('lang', '');
+(: QUERY BODY ============================================================== :)
let $edition := request:get-parameter('edition', '')
let $uri := request:get-parameter('uri', '')
@@ -53,6 +45,6 @@ return
diff --git a/add/data/xql/getAnnotations.xql b/add/data/xql/getAnnotations.xql
index 99a73d40b..7b4e86a7c 100644
--- a/add/data/xql/getAnnotations.xql
+++ b/add/data/xql/getAnnotations.xql
@@ -1,24 +1,7 @@
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 .
-
- ID: $Id: getAnnotations.xql 1324 2012-05-15 13:59:35Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
: Returns a JSON representation of all Annotations of a document.
@@ -26,30 +9,41 @@ xquery version "3.1";
: @author Daniel Röwenstrunk
:)
-import module namespace annotation="http://www.edirom.de/xquery/annotation" at "../xqm/annotation.xqm";
+(: IMPORTS ================================================================= :)
+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";
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+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";
+(: OPTION DECLARATIONS ===================================================== :)
+
declare option output:method "text";
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 :=
+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)}
+ '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
+
+return
+ serialize($map, $options)
diff --git a/add/data/xql/getAnnotationsInRendering.xql b/add/data/xql/getAnnotationsInRendering.xql
index 78d744e85..7b0709a46 100644
--- a/add/data/xql/getAnnotationsInRendering.xql
+++ b/add/data/xql/getAnnotationsInRendering.xql
@@ -1,75 +1,66 @@
-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 .
-
- ID: $Id: getAnnotationsOnPage.xql 1457 2012-10-12 08:05:03Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns a JSON sequence with all anotations on a specific page.
-
+
@author Daniel Röwenstrunk
:)
+(: IMPORTS ================================================================= :)
+
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";
+(: NAMESPACE DECLARATIONS ================================================== :)
-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";
+(: OPTION DECLARATIONS ===================================================== :)
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)
+ (: TODO update XPath e.g., parent::node() at the end or similar :)
+ 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('
- {',
- '"id": "', $id, '", ',
- '"measureId": "', $measureId, '", ',
- '"fn": "loadLink(\"', $uri, '\")", ',
- '"uri": "', $uri, '", ',
- '"priority": "', $prio, '", ',
- '"categories": "', $cat, '"',
- '}')
+ 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 (:TODO map instead of concat :)
+ concat('
+ {',
+ '"id": "', $id, '", ',
+ '"measureId": "', $measureId, '", ',
+ '"fn": "loadLink(\"', $uri, '\")", ',
+ '"uri": "', $uri, '", ',
+ '"priority": "', $prio, '", ',
+ '"categories": "', $cat, '"',
+ '}'
+ )
};
let $edition := request:get-parameter('edition', '')
let $uri := request:get-parameter('uri', '')
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 (
- concat('[',
- string-join($annots, ','),
- ']')
-)
+return
+ concat(
+ '[',
+ string-join($annots, ','),
+ ']'
+ )
diff --git a/add/data/xql/getAnnotationsInText.xql b/add/data/xql/getAnnotationsInText.xql
index d57ed2704..63d3d2e39 100644
--- a/add/data/xql/getAnnotationsInText.xql
+++ b/add/data/xql/getAnnotationsInText.xql
@@ -1,83 +1,73 @@
-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 .
-
- ID: $Id: getAnnotationsInText.xql 1279 2012-03-19 13:16:43Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns a JSON sequence with all anotations in a specific text.
-
+
@author Daniel Röwenstrunk
:)
-declare namespace mei="http://www.music-encoding.org/ns/mei";
-declare namespace xlink="http://www.w3.org/1999/xlink";
+(: NAMESPACE DECLARATIONS ================================================== :)
-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 ft = "http://exist-db.org/xquery/lucene";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
(:~
Finds all annotations in all works.
-
+
@param $elems The elements to check (most likely measures and zones)
@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('
- {',
- 'id: "', $id, '", ',
- 'plist: [', $plist, '], ',
- 'svgList: [], ',
- 'fn: "loadLink(\"', $uri, '\")", ',
- 'uri: "', $uri, '", ',
- 'priority: "', $prio, '", ',
- 'categories: "', $cat, '"',
- '}')
+ 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 (: TODO map instead of concat :)
+ concat('
+ {',
+ 'id: "', $id, '", ',
+ 'plist: [', $plist, '], ',
+ 'svgList: [], ',
+ 'fn: "loadLink(\"', $uri, '\")", ',
+ 'uri: "', $uri, '", ',
+ 'priority: "', $prio, '", ',
+ 'categories: "', $cat, '"',
+ '}'
+ )
};
let $uri := request:get-parameter('uri', '')
let $uriSharp := concat($uri, '#')
let $annotations := local:findAnnotations($uri)
-return
- concat('[',
- string-join(local:getAnnotations($uriSharp, $annotations), ','),
- ']')
+return (: TODO map instead of concat :)
+ concat(
+ '[',
+ string-join(local:getAnnotations($uriSharp, $annotations), ','),
+ ']'
+ )
diff --git a/add/data/xql/getAnnotationsOnPage.xql b/add/data/xql/getAnnotationsOnPage.xql
index 0dbba5837..c0b79e309 100644
--- a/add/data/xql/getAnnotationsOnPage.xql
+++ b/add/data/xql/getAnnotationsOnPage.xql
@@ -1,170 +1,179 @@
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 .
-
- ID: $Id: getAnnotationsOnPage.xql 1457 2012-10-12 08:05:03Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
: Returns a JSON sequence with all anotations on a specific page.
- :
+ :
: @author Daniel Röwenstrunk
: @author Benjamin W. Bohl
:)
+(: IMPORTS ================================================================= :)
+
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";
+(: NAMESPACE DECLARATIONS ================================================== :)
-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 ft = "http://exist-db.org/xquery/lucene";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace svg = "http://www.w3.org/2000/svg";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option output:method "json";
declare option output:media-type "application/json";
-(: Returns a JSON array of annotations
- :
- : @param sourceUriSharp the xmldb-uri of a mei-source with a trailing #
- : @param surfaceId the xml:id of a mei:surface element
- : @param annotations the mei:annotation elements to consider
+(:~
+ : Returns a JSON array of annotations
+ :
+ : @param $sourceUriSharp the xmldb-uri of a mei-source with a trailing #
+ : @param $surfaceId the xml:id of a mei:surface element
+ : @param $annotations the mei:annotation elements to consider
+ :
: @returns a JSON array of annotations
:)
-
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 :=
+ 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 $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
+ }
};
(:~
: Returns all annotations in all works of a edirom-edition containing references to a list of IDs from one source
- :
+ :
: @param $edition The xmldb-uri to the edirom-edition file
: @param $uri The xmldb-uri to the source-file
: @param $elemIds The element-IDs to check (most likely measures and zones)
: @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
- (:
- 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')]
- )
+ 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')]
+ )
};
(:~
- Returns a JSON representation of all participants of an annotation
-
- @param $annotId The id of the annotation to process
- @param $plist The list of participants referenced by the annotation
- @param $elem A sequence of elements which could be relevant
- @returns A JSON representation of the perticipants
-:)
+ : Returns a JSON representation of all participants of an annotation
+ :
+ : @param $annotId The id of the annotation to process
+ : @param $plist The list of participants referenced by the annotation
+ : @param $elem A sequence of elements which could be relevant
+ :
+ : @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]
+ }
};
(:~
- Returns a JSON representation of all participants of an annotation
-
- @param $annotId The id of the annotation to process
- @param $plist The list of participants referenced by the annotation
- @param $elem A sequence of elements which could be relevant
- @returns A JSON representation of the perticipants
-:)
+ : Returns a JSON representation of all participants of an annotation
+ :
+ : @param $annotId The id of the annotation to process
+ : @param $plist The list of participants referenced by the annotation
+ : @param $elem A sequence of elements which could be relevant
+ :
+ : @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
+ return
for $svg in $participants
let $id := $svg/@id
- return map {
- 'id': $annoId || '__' || $id,
- 'svg': $svg
- }
+ return
+ map {
+ 'id': $annoId || '__' || $id,
+ 'svg': $svg
+ }
};
(:~
- : Reads the coordinates of an element
- :
+ : Reads the coordinates of an element referenced from an mei:annot/@plist
+ : If the element name is 'measure' or 'staff' theses will be fetched from
+ : a zone referenced with the @facs attribute
+ : If the zone does not have an @ulx attribute or if there is no zone being referenced
+ : the function will return -1 as avalue for all coordinates
+ :
: @param $participant The element to process
+ :
: @returns A sequence with coordinates (ulx, uly, lrx, lry)
+ : @error A fallback sequence wit -1 as all values: (-1, -1, -1, -1)
:)
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 +185,12 @@ let $surfaceId := request:get-parameter('pageId', '')
let $surface := $mei/id($surfaceId)
let $zones := $surface//mei:zone
-let $measureLike :=
+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 $ref := concat('#', $id)
+ return
+ $mei//*[$ref = tokenize(@facs, '\s')]
+
let $svgLike := $surface//svg:svg
let $targetLike := $zones | $measureLike | $svgLike
@@ -190,4 +200,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..99548c7f9 100644
--- a/add/data/xql/getAudioPlayer.xql
+++ b/add/data/xql/getAudioPlayer.xql
@@ -1,264 +1,355 @@
-xquery version "3.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2015 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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.
+import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
-:)
+(: NAMESPACE DECLARATIONS ================================================== :)
-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 request = "http://exist-db.org/xquery/request";
-declare namespace request="http://exist-db.org/xquery/request";
-declare namespace mei="http://www.music-encoding.org/ns/mei";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";
+(: QUERY BODY ============================================================== :)
+
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 $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
- '{
- "name": "' || replace($recTitle, '"', '\\"') || '"
- ,"artist": "' || replace($artist, '"', '\\"') || '"
- ,"album": "' || replace($album, '"', '\\"') || '"
- ,"url": "' || $avFile || '"
- ,"live": false' ||
- ',"cover_art_url": "' || $albumCover || '"' || '
- }'
+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
+ (:TODO map instead of concatenation :)
+ '{
+ "name": "' || replace($recTitle, '"', '\\"') || '"
+ ,"artist": "' || replace($artist, '"', '\\"') || '"
+ ,"album": "' || replace($album, '"', '\\"') || '"
+ ,"url": "' || $avFile || '"
+ ,"live": false' ||
+ ',"cover_art_url": "' || $albumCover || '"' || '
+ }'
let $audioConfig := '{
- "songs": [' ||
- string-join($records, ', ')
- || '],
- "default_album_art": "../../resources/img/no-cover.png"
- }'
+ "songs": [' ||
+ 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..95ef53244 100644
--- a/add/data/xql/getChapters.xql
+++ b/add/data/xql/getChapters.xql
@@ -1,107 +1,127 @@
-xquery version "3.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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.
+import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
+(: NAMESPACE DECLARATIONS ================================================== :)
- ID: $Id: getChapters.xql 1460 2012-10-15 15:58:35Z niko $
-:)
+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";
-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 xmldb="http://exist-db.org/xquery/xmldb";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: FUNCTION DECLARATIONS =================================================== :)
+
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)
+(:TODO replace with fn:format-integer:)
+ 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
- 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
- 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)
+ (:TODO map instead of concat :)
+ 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
+ (:TODO map instead of concat :)
+ 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
- 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()
+ 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
+ ()
-return concat('[', string-join($ret, ','), ']')
\ No newline at end of file
+return
+ concat('[', string-join($ret, ','), ']')
diff --git a/add/data/xql/getConcordances.xql b/add/data/xql/getConcordances.xql
index c3f26fffe..784349162 100644
--- a/add/data/xql/getConcordances.xql
+++ b/add/data/xql/getConcordances.xql
@@ -1,51 +1,45 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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.
+import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
+(: NAMESPACE DECLARATIONS ================================================== :)
- ID: $Id: getConcordances.xql 1219 2012-01-20 08:33:28Z daniel $
-:)
+declare namespace edirom = "http://www.edirom.de/ns/1.3";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
-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 xmldb="http://exist-db.org/xquery/xmldb";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: VARIABLE DECLARATIONS =================================================== :)
+
declare variable $lang := request:get-parameter('lang', '');
+(: FUNCTION DECLARATIONS =================================================== :)
+
declare function local:getGroups($parent) {
- if($parent/edirom:groups)
- then(
- concat('{', 'label: "', eutil:getLocalizedName($parent/edirom:groups, $lang), '", groups: [', local:getSingleGroups($parent/edirom:groups), ']}')
- )
- else(string('null'))
+ if ($parent/edirom:groups) then (
+ concat('
+ {', 'label: "', eutil:getLocalizedName($parent/edirom:groups, $lang),
+ '", groups: [', local:getSingleGroups($parent/edirom:groups), ']}'
+ )
+ ) else
+ (string('null'))
};
declare function local:getSingleGroups($parent) {
string-join(
for $group in $parent/edirom:group
return
- concat('
+ concat('
{',
'name: "', eutil:getLocalizedName($group, $lang), '", ',
'connections: ', local:getConnections($group),
@@ -54,18 +48,22 @@ declare function local:getSingleGroups($parent) {
};
declare function local:getConnections($parent) {
- if($parent/edirom:connections)
- then(
- concat('{', 'label: "', eutil:getLocalizedName($parent/edirom:connections, $lang), '", connections: [', local:getSingleConnections($parent/edirom:connections), ']}')
- )
- else(string('null'))
+ if ($parent/edirom:connections) then (
+ concat(
+ '{',
+ 'label: "', eutil:getLocalizedName($parent/edirom:connections, $lang), '",
+ connections: [', local:getSingleConnections($parent/edirom:connections),
+ ']}'
+ )
+ ) else
+ (string('null'))
};
declare function local:getSingleConnections($parent) {
string-join(
for $connection in $parent/edirom:connection
return
- concat('
+ concat('
{',
'name: "', $connection/string(@name), '", ',
'plist: "', $connection/@plist, '"',
@@ -73,6 +71,8 @@ declare function local:getSingleConnections($parent) {
, ',')
};
+(: QUERY BODY ============================================================== :)
+
let $id := request:get-parameter('id', '')
let $mei := doc($id)/root()
let $workId := request:get-parameter('workId', '')
@@ -80,18 +80,17 @@ let $work := $mei/id($workId)
let $concordances := $work//edirom:concordance
return (
- concat('[',
-
- string-join(
- for $concordance in $concordances
- return
+ concat(
+ '[',
+ string-join(
+ 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..6d5e11800 100644
--- a/add/data/xql/getEdition.xql
+++ b/add/data/xql/getEdition.xql
@@ -1,24 +1,7 @@
-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 .
-
- ID: $Id: getEdition.xql 1324 2012-05-15 13:59:35Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
: Returns a JSON representation of an Edition.
@@ -26,9 +9,17 @@ xquery version "1.0";
: @author Daniel Röwenstrunk
:)
-import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
+(: IMPORTS ================================================================= :)
+
+import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: QUERY BODY ============================================================== :)
+
let $uri := request:get-parameter('id', '')
-return edition:toJSON($uri)
\ No newline at end of file
+return
+ (:TODO use map an serialization options :)
+ edition:toJSON($uri)
diff --git a/add/data/xql/getEditionURI.xql b/add/data/xql/getEditionURI.xql
index 22256a695..e2c862530 100644
--- a/add/data/xql/getEditionURI.xql
+++ b/add/data/xql/getEditionURI.xql
@@ -1,22 +1,7 @@
-xquery version "3.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2014 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.
+ :)
(:~
: Returns the URI of the first found Edition.
@@ -24,12 +9,19 @@ xquery version "3.0";
: @author Daniel Röwenstrunk
:)
-import module namespace edition="http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
+(: IMPORTS ================================================================= :)
+
+import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: QUERY BODY ============================================================== :)
+
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))
diff --git a/add/data/xql/getExtendedStaff.xql b/add/data/xql/getExtendedStaff.xql
index 05f0674f3..c2881cb84 100644
--- a/add/data/xql/getExtendedStaff.xql
+++ b/add/data/xql/getExtendedStaff.xql
@@ -1,58 +1,98 @@
-xquery version "3.0";
+xquery version "3.1";
-declare namespace request="http://exist-db.org/xquery/request";
-declare namespace mei="http://www.music-encoding.org/ns/mei";
+(:
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
-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";
+(: IMPORTS ================================================================= :)
import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace system = "http://exist-db.org/xquery/system";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare namespace transform = "http://exist-db.org/xquery/transform";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
+
declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";
+(: QUERY BODY ============================================================== :)
+
let $uri := request:get-parameter('uri', '')
let $edition := request:get-parameter('edition', '')
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..d77476a4e 100644
--- a/add/data/xql/getHeader.xql
+++ b/add/data/xql/getHeader.xql
@@ -1,51 +1,67 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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.
+import module namespace eutil = "http://www.edirom.de/xquery/util" at "../xqm/util.xqm";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
+(: NAMESPACE DECLARATIONS ================================================== :)
- ID: $Id: getHeader.xql 1455 2012-10-11 10:42:55Z daniel $
-:)
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace system = "http://exist-db.org/xquery/system";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+declare namespace transform = "http://exist-db.org/xquery/transform";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
-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";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";
+(: QUERY BODY ============================================================== :)
+
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
+ ()
diff --git a/add/data/xql/getHelp.xql b/add/data/xql/getHelp.xql
index 09dc6cbf0..2c91cb5bf 100644
--- a/add/data/xql/getHelp.xql
+++ b/add/data/xql/getHelp.xql
@@ -1,26 +1,14 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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 .
-
-:)
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";
+(: QUERY BODY ============================================================== :)
+
let $lang := request:get-parameter('lang', 'en')
let $idPrefix := request:get-parameter('idPrefix', '')
@@ -29,10 +17,29 @@ 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'),
+
+
+
+ )
+
diff --git a/add/data/xql/getInternalIdType.xql b/add/data/xql/getInternalIdType.xql
index 43cd7314b..264f6be09 100644
--- a/add/data/xql/getInternalIdType.xql
+++ b/add/data/xql/getInternalIdType.xql
@@ -1,63 +1,62 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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 .
+import module namespace functx = "http://www.functx.com";
- ID: $Id: getInternalIdType.xql 1289 2012-03-26 13:11:43Z daniel $
-:)
+(: NAMESPACE DECLARATIONS ================================================== :)
-declare namespace request="http://exist-db.org/xquery/request";
-declare namespace mei="http://www.music-encoding.org/ns/mei";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
-import module namespace functx = "http://www.functx.com";
+(: OPTION DECLARATIONS ===================================================== :)
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)
+(: QUERY BODY ============================================================== :)
+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 $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..39799c91e 100644
--- a/add/data/xql/getLanguageFile.xql
+++ b/add/data/xql/getLanguageFile.xql
@@ -1,37 +1,28 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(:~
+ : Returns a language file as JSON or XML.
+ :
+ : @author Daniel Röwenstrunk
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
+import module namespace edition = "http://www.edirom.de/xquery/edition" at "../xqm/edition.xqm";
- ID: $Id: getLanguageFile.xql 1455 2012-10-11 10:42:55Z daniel $
-:)
+(: NAMESPACE DECLARATIONS ================================================== :)
-(:~
- Returns a language file as JSON or XML.
-
- @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";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=xhtml media-type=text/html omit-xml-declaration=yes indent=yes";
+(: QUERY BODY ============================================================== :)
+
let $lang := request:get-parameter('lang', '')
let $mode := request:get-parameter('mode', '')
let $edition := request:get-parameter('edition', '')
@@ -43,24 +34,22 @@ let $file := doc(concat('../locale/edirom-lang-', $lang, '.xml'))
let $projectFile := doc(edition:getLanguageFileURI($edition, $lang))
return
- 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), '"')
- ), ','),
- '}',
- '}')
- )
- else($file)
-
\ No newline at end of file
+ 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), '"')
+ ), ','),
+ '}',
+ '}'
+ )
+ ) else
+ ($file)
diff --git a/add/data/xql/getLinkTarget.xql b/add/data/xql/getLinkTarget.xql
index 86dcbca9a..db7821697 100644
--- a/add/data/xql/getLinkTarget.xql
+++ b/add/data/xql/getLinkTarget.xql
@@ -1,13 +1,9 @@
xquery version "3.1";
(:
-For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
-declare namespace html = "http://www.w3.org/1999/xhtml";
-declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
-declare namespace mei = "http://www.music-encoding.org/ns/mei";
-declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
-declare namespace tei = "http://www.tei-c.org/ns/1.0";
+(: IMPORTS ================================================================= :)
import module namespace functx = "http://www.functx.com";
import module namespace request = "http://exist-db.org/xquery/request";
@@ -18,118 +14,105 @@ import module namespace source = "http://www.edirom.de/xquery/source" at "../xqm
import module namespace teitext = "http://www.edirom.de/xquery/teitext" at "../xqm/teitext.xqm";
import module namespace work = "http://www.edirom.de/xquery/work" at "../xqm/work.xqm";
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+declare namespace html = "http://www.w3.org/1999/xhtml";
+declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare namespace tei = "http://www.tei-c.org/ns/1.0";
+
+(: OPTION DECLARATIONS ===================================================== :)
+
declare option output:method "json";
declare option output:media-type "application/json";
+(: VARIABLE DECLARATIONS =================================================== :)
+
declare variable $lang := request:get-parameter('lang', '');
declare variable $uri := request:get-parameter('uri', '');
+(: FUNCTION DECLARATIONS =================================================== :)
+
(:~
: Returns a view for an edirom object
:)
declare function local:getView($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)? {
let $baseMap := map {
'type': substring-after($type, '_'),
- 'uri': if ($type = ('mei_textView', 'desc_xmlView')) then
- string(($doc//mei:annot[@type = 'descLink'])[1]/@plist)
- else
- $docUri
+ 'uri':if ($type = ('mei_textView', 'desc_xmlView')) then
+ string(($doc//mei:annot[@type = 'descLink'])[1]/@plist)
+ else
+ $docUri
}
(: optionally set label for some views:)
let $labeled.map :=
- if ($type = 'mei_textView')
- then
- (map:put($baseMap, 'label', 'Quellenbeschreibung'))
- else
- if ($type = 'desc_xmlView')
- then
+ if ($type = 'mei_textView') then
+ (map:put($baseMap, 'label', 'Quellenbeschreibung'))
+ else if ($type = 'desc_xmlView') then
(map:put($baseMap, 'label', 'XML Quellenbeschreibung'))
else
($baseMap)
- (: whether to set the view as default view:)
+ (: whether to set the view as default view:)
let $defaultViewed.map :=
- if ($type = ('mei_sourceView',
- 'mei_audioView',
- 'tei_textView',
- 'tei_facsimileView',
- 'tei_textFacsimileSplitView',
- 'mei_annotationView',
- 'mei_verovioView'))
- then
- (map:put($labeled.map, 'defaultView', true()))
- else
- ($labeled.map)
-
+ if ($type = (
+ 'mei_sourceView',
+ 'mei_audioView',
+ 'tei_textView',
+ 'tei_facsimileView',
+ 'tei_textFacsimileSplitView',
+ 'mei_annotationView',
+ 'mei_verovioView')
+ ) then
+ (map:put($labeled.map, 'defaultView', true()))
+ else
+ ($labeled.map)
- (: xpath check whether any given view is supported :)
+ (: xpath check whether any given view is supported :)
let $hasView :=
- if ($type = 'desc_summaryView')
- then
- (true())
-
- else
- if ($type = 'desc_headerView')
- then
+ if ($type = 'desc_summaryView') then
+ (true())
+
+ else if ($type = 'desc_headerView') then
(exists($doc//mei:meiHead or $doc//tei:teiHeader))
- else
- if ($type = 'mei_textView')
- then
- (exists($doc//mei:annot[@type = 'descLink']))
+ else if ($type = 'mei_textView') then
+ (exists($doc//mei:annot[@type = 'descLink']))
+
+ else if ($type = 'mei_sourceView') then
+ (exists($doc//mei:facsimile//mei:graphic[@type = 'facsimile']))
+
+ else if ($type = 'mei_audioView') then
+ (exists($doc//mei:recording))
+
+ else if ($type = 'mei_verovioView') then
+ (exists($doc//mei:body//mei:measure) and exists($doc//mei:body//mei:note))
+
+ else if ($type = 'tei_textView') then
+ (exists($doc//tei:body[matches(.//text(), '[^\s]+')]))
+
+ else if ($type = 'tei_facsimileView') then
+ (exists($doc//tei:facsimile//tei:graphic))
+
+ else if ($type = 'tei_textFacsimileSplitView') then
+ (exists($doc//tei:facsimile//tei:graphic) and exists($doc//tei:pb[@facs]))
+
+ else if ($type = 'mei_annotationView') then
+ (exists($doc//mei:annot[@type = 'editorialComment']))
+
+ else if ($type = 'xml_xmlView') then
+ (true())
+
+ else if ($type = 'desc_xmlView') then
+ (exists($doc//mei:annot[@type = 'descLink']))
- else
- if ($type = 'mei_sourceView')
- then
- (exists($doc//mei:facsimile//mei:graphic[@type = 'facsimile']))
-
- else
- if ($type = 'mei_audioView')
- then
- (exists($doc//mei:recording))
-
- else
- if ($type = 'mei_verovioView')
- then
- (exists($doc//mei:body//mei:measure) and exists($doc//mei:body//mei:note))
-
- else
- if ($type = 'tei_textView')
- then
- (exists($doc//tei:body[matches(.//text(), '[^\s]+')]))
-
- else
- if ($type = 'tei_facsimileView')
- then
- (exists($doc//tei:facsimile//tei:graphic))
-
- else
- if ($type = 'tei_textFacsimileSplitView')
- then
- (exists($doc//tei:facsimile//tei:graphic) and exists($doc//tei:pb[@facs]))
-
- else
- if ($type = 'mei_annotationView')
- then
- (exists($doc//mei:annot[@type = 'editorialComment']))
-
- else
- if ($type = 'xml_xmlView')
- then
- (true())
-
- else
- if ($type = 'desc_xmlView')
- then
- (exists($doc//mei:annot[@type = 'descLink']))
-
- else
- (false())
+ else
+ (false())
return
- if ($hasView)
- then
+ if ($hasView) then
($defaultViewed.map)
else
()
@@ -141,24 +124,24 @@ declare function local:getView($type as xs:string, $docUri as xs:string, $doc as
declare function local:getViews($type as xs:string, $docUri as xs:string, $doc as node()+) as map(*)* {
let $views := (
- (:'desc_summaryView',:)
- (:'desc_headerView',:)
- 'mei_textView',
- 'mei_sourceView',
- 'mei_audioView',
- 'mei_verovioView',
- 'tei_textView',
- 'tei_facsimileView',
- 'tei_textFacsimileSplitView',
- 'mei_annotationView',
- 'xml_xmlView',
- 'desc_xmlView'
+ (:'desc_summaryView',:)
+ (:'desc_headerView',:)
+ 'mei_textView',
+ 'mei_sourceView',
+ 'mei_audioView',
+ 'mei_verovioView',
+ 'tei_textView',
+ 'tei_facsimileView',
+ 'tei_textFacsimileSplitView',
+ 'mei_annotationView',
+ 'xml_xmlView',
+ 'desc_xmlView'
)
let $maps :=
- for $view in $views
- return
- local:getView($view, $docUri, $doc)
+ for $view in $views
+ return
+ local:getView($view, $docUri, $doc)
return
$maps
@@ -168,179 +151,171 @@ declare function local:getViews($type as xs:string, $docUri as xs:string, $doc a
: Returns the window title for an edirom-object
:)
declare function local:getWindowTitle($doc as node()+, $type as xs:string) as xs:string {
+
(: Work :)
- if (exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium)))
- then
+ if (exists($doc//mei:mei) and exists($doc//mei:workDesc/mei:work) and not(exists($doc//mei:perfMedium))) then
(eutil:getLocalizedTitle(($doc//mei:work)[1]/mei:titleStmt[1], $lang))
+ else if (exists($doc/root()/mei:work)) then
+ (eutil:getLocalizedTitle($doc/root()/mei:work, $lang))
+
+ (: Recording :)
+ else if (exists($doc//mei:mei) and exists($doc//mei:recording)) then
+ (eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang))
+
+ (: Source / Score :)
+ else if ($type = 'source' and exists($doc//mei:manifestation/mei:titleStmt)) then
+ (string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang),
+ ($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
+ => normalize-space())
+ else if ($type = 'source' and exists($doc//mei:source/mei:titleStmt)) then
+ (string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang),
+ ($doc//mei:source)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
+ => normalize-space())
+
+ (: MEI fallback if no title is found :)
+ else if (exists($doc//mei:mei) and exists(($doc//mei:titleStmt)[1])) then
+ (eutil:getLocalizedTitle(($doc//mei:titleStmt)[1], $lang))
+
+ (: Text :)
+ else if (exists($doc/tei:TEI)) then
+ (eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang))
+
+ (: HTML :)
+ else if ($type = 'html') then
+ ($doc//head/data(title))
+
else
- if (exists($doc/root()/mei:work))
- then
- (eutil:getLocalizedTitle($doc/root()/mei:work, $lang))
-
- (: Recording :)
- else
- if (exists($doc//mei:mei) and exists($doc//mei:recording))
- then
- (eutil:getLocalizedTitle($doc//mei:fileDesc/mei:titleStmt[1], $lang))
-
- (: Source / Score :)
- else
- if ($type = 'source' and exists($doc//mei:manifestation/mei:titleStmt))
- then
- (string-join((eutil:getLocalizedTitle(($doc//mei:manifestation)[1]/mei:titleStmt[1], $lang),
- ($doc//mei:manifestation)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
- => normalize-space())
- else
- if ($type = 'source' and exists($doc//mei:source/mei:titleStmt))
- then
- (string-join((eutil:getLocalizedTitle(($doc//mei:source)[1]/mei:titleStmt[1], $lang),
- ($doc//mei:source)[1]//mei:identifier[lower-case(@type) = 'shelfmark'][1]), ' | ')
- => normalize-space())
-
- (: MEI fallback if no title is found :)
- else
- if (exists($doc//mei:mei) and exists(($doc//mei:titleStmt)[1]))
- then
- (eutil:getLocalizedTitle(($doc//mei:titleStmt)[1], $lang))
-
- (: Text :)
- else
- if (exists($doc/tei:TEI))
- then
- (eutil:getLocalizedTitle($doc//tei:fileDesc/tei:titleStmt[1], $lang))
-
- (: HTML :)
- else
- if ($type = 'html')
- then
- ($doc//head/data(title))
-
- else
- (string('unknown'))
+ (string('unknown'))
};
-let $uriParams := if (contains($uri, '?')) then
- (substring-after($uri, '?'))
-else
- ('')
-let $uri := if (contains($uri, '?')) then
- (replace($uri, '[?&](term|path)=[^&]*', ''))
-else
- ($uri)
-let $docUri := if (contains($uri, '#')) then
- (substring-before($uri, '#'))
-else
- ($uri)
-let $internalId := if (contains($uri, '#')) then
- (substring-after($uri, '#'))
-else
- ()
-let $internalIdParam := if (contains($internalId, '?')) then
- (concat('?', substring-after($internalId, '?')))
-else
- ('')
-let $internalId := if (contains($internalId, '?')) then
- (substring-before($internalId, '?'))
-else
- ($internalId)
-
-let $term := if (contains($uriParams, 'term=')) then
- (substring-after($uriParams, 'term='))
-else
- ()
-let $term := if (contains($term, '&')) then
- (substring-before($term, '&'))
-else
- ($term)
-
-let $path := if (contains($uriParams, 'path=')) then
- (substring-after($uriParams, 'path='))
-else
- ()
-let $path := if (contains($path, '&')) then
- (substring-before($path, '&'))
-else
- ($path)
+(: QUERY BODY ============================================================== :)
+
+let $uriParams :=
+ if (contains($uri, '?')) then
+ (substring-after($uri, '?'))
+ else
+ ('')
+
+let $uri :=
+ if (contains($uri, '?')) then
+ (replace($uri, '[?&](term|path)=[^&]*', ''))
+ else
+ ($uri)
+
+let $docUri :=
+ if (contains($uri, '#')) then
+ (substring-before($uri, '#'))
+ else
+ ($uri)
+
+let $internalId :=
+ if (contains($uri, '#')) then
+ (substring-after($uri, '#'))
+ else
+ ()
+
+let $internalIdParam :=
+ if (contains($internalId, '?')) then
+ (concat('?', substring-after($internalId, '?')))
+ else
+ ('')
+
+let $internalId :=
+ if (contains($internalId, '?')) then
+ (substring-before($internalId, '?'))
+ else
+ ($internalId)
+
+let $term :=
+ if (contains($uriParams, 'term=')) then
+ (substring-after($uriParams, 'term='))
+ else
+ ()
+
+let $term :=
+ if (contains($term, '&')) then
+ (substring-before($term, '&'))
+ else
+ ($term)
+
+let $path :=
+ if (contains($uriParams, 'path=')) then
+ (substring-after($uriParams, 'path='))
+ else
+ ()
+
+let $path :=
+ if (contains($path, '&')) then
+ (substring-before($path, '&'))
+ else
+ ($path)
let $doc := eutil:getDoc($docUri)
+
let $internal := $doc/id($internalId)
let $edition := request:get-parameter('edition', '')
(: 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)
+ if (exists($internal))
then
- (
-
- let $mdivId := functx:substring-before-last(substring-after($internalId, 'measure_'), '_')
- let $measureN := functx:substring-after-last($internalId, '_')
- return
- ($doc/id($mdivId)//mei:measure[@n eq $measureN])[1]
- )
- else
($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
+ ($doc/id($mdivId)//mei:measure[@n eq $measureN])[1]
+ ) else
+ ($internal)
)
-let $type := (: Work :)
-if (exists($doc//mei:mei) and exists($doc//mei:work) and not(exists($doc//mei:perfMedium)))
-then
- (string('work'))
+let $type :=
+ (: Work :)
+ if (exists($doc//mei:mei) and exists($doc//mei:work) and not(exists($doc//mei:perfMedium))) then
+ (string('work'))
(: Recording :)
-else
- if (exists($doc//mei:mei) and exists($doc//mei:recording))
- then
+ else if (exists($doc//mei:mei) and exists($doc//mei:recording)) then
(string('recording'))
-
- (: Source / Score :)
+
+ (: Source / Score :)
+ else if (source:isSource($docUri)) then
+ (string('source'))
+
+ (: Text :)
+ else if (exists($doc/tei:TEI)) then
+ (string('text'))
+
+ (: HTML :)
+ else if (exists($doc/html) or exists($doc/html:html)) then
+ (string('html'))
+
+ else if (contains($docUri, '.html')) then
+ (string('html'))
+
else
- if (source:isSource($docUri))
- then
- (string('source'))
-
- (: Text :)
- else
- if (exists($doc/tei:TEI))
- then
- (string('text'))
-
- (: HTML :)
- else
- if (exists($doc/html) or exists($doc/html:html))
- then
- (string('html'))
-
- else
- if (contains($docUri, '.html'))
- then
- (string('html'))
-
- else
- (string('unknown'))
-
-let $internalIdType := if (exists($internal))
-then
- (local-name($internal))
-else
- ('unknown')
+ (string('unknown'))
+
+let $internalIdType :=
+ if (exists($internal)) then
+ (local-name($internal))
+ else
+ ('unknown')
let $map :=
-map {
- 'type': $type,
- 'title': local:getWindowTitle($doc, $type),
- 'doc': $docUri,
- 'views': array {local:getViews($type, $docUri, $doc)},
- 'internalId': $internalId || $internalIdParam,
- 'term': $term,
- 'path': $path,
- 'internalIdType': $internalIdType
-}
+ map {
+ 'type': $type,
+ 'title': local:getWindowTitle($doc, $type),
+ 'doc': $docUri,
+ 'views': array {local:getViews($type, $docUri, $doc)},
+ 'internalId': $internalId || $internalIdParam,
+ 'term': $term,
+ 'path': $path,
+ 'internalIdType': $internalIdType
+ }
return
$map
diff --git a/add/data/xql/getMeasure.xql b/add/data/xql/getMeasure.xql
index 99e592b6f..5ba36eba1 100644
--- a/add/data/xql/getMeasure.xql
+++ b/add/data/xql/getMeasure.xql
@@ -1,53 +1,61 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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.
+import module namespace functx = "http://www.functx.com";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
+(: NAMESPACE DECLARATIONS ================================================== :)
- ID: $Id: getMeasurePage.xql 1254 2012-02-01 14:07:25Z daniel $
-:)
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+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 request = "http://exist-db.org/xquery/request";
+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";
+(: OPTION DECLARATIONS ===================================================== :)
-import module namespace functx = "http://www.functx.com";
+declare option output:method "text";
+declare option output:media-type "text/plain";
+declare option output:omit-xml-declaration "yes";
+
+(:TODO serialize to JSON :)
-declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: QUERY BODY ============================================================== :)
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
+ (:TODO map and serialize to JSON instead of concat :)
concat('{',
- 'measureId:"', $measureId, '",',
- 'movementId:"', $movementId, '",',
- 'measureCount:"', $measureCount, '"',
- '}')
\ No newline at end of file
+ 'measureId:"', $measureId, '",',
+ 'movementId:"', $movementId, '",',
+ 'measureCount:"', $measureCount, '"',
+ '}')
diff --git a/add/data/xql/getMeasurePage.xql b/add/data/xql/getMeasurePage.xql
index a20ce63ce..38aac2cd5 100644
--- a/add/data/xql/getMeasurePage.xql
+++ b/add/data/xql/getMeasurePage.xql
@@ -1,41 +1,28 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: NAMESPACE DECLARATIONS ================================================== :)
- 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.
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
-
- 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 xmldb="http://exist-db.org/xquery/xmldb";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: FUNCTION DECLARATIONS =================================================== :)
+
declare function local:findMeasure($mei, $movementId, $measureIdName) {
let $m := $mei/id($measureIdName)
return
- if($m)
- then($m)
- else(
- ($mei/id($movementId)//mei:measure[@n eq $measureIdName])[1]
- )
+ 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,25 +31,29 @@ 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), '"',
- '}')
+
+ 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), '"',
+ '}'
+ )
};
+(: QUERY BODY ============================================================== :)
+
let $id := request:get-parameter('id', '')
let $measureIdName := request:get-parameter('measure', '')
let $movementId := request:get-parameter('movementId', '')
@@ -71,20 +62,31 @@ let $measureCount := request:get-parameter('measureCount', '1')
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 $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)]
+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 $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
- 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)
- ), ','),
- ']')
\ No newline at end of file
+ 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)
+ ), ','),
+ ']')
diff --git a/add/data/xql/getMeasures.xql b/add/data/xql/getMeasures.xql
index ce0af33b3..4e5d0ee0f 100644
--- a/add/data/xql/getMeasures.xql
+++ b/add/data/xql/getMeasures.xql
@@ -1,122 +1,126 @@
xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: IMPORTS ================================================================= :)
- 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.
+import module namespace functx = "http://www.functx.com";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
-
-:)
+import module namespace eutil = "http://www.edirom.de/xquery/util" at "/db/apps/Edirom-Online/data/xqm/util.xqm";
-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";
+(: NAMESPACE DECLARATIONS ================================================== :)
-declare namespace xmldb="http://exist-db.org/xquery/xmldb";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
-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";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: FUNCTION DECLARATIONS =================================================== :)
+
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)
+ 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)
+
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))])
- 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, '",
- voice: "', $voiceRef,
- '", partLabel: "', eutil:getPartLabel($measure, 'measure'),
- '"}')
- return
- concat('{',
- '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):)
+ 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))])
+ 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('{',
+ concat(
+ '{id:"', $measure/@xml:id, '",
+ voice: "', $voiceRef,
+ '", partLabel: "', eutil:getPartLabel($measure, 'measure'),
+ '"}'
+ )
+ return
+ concat(
+ '{',
+ '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 (
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('{',
+ 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. :)
- '}')
+ '}'
+ )
)
)
};
+(: QUERY BODY ============================================================== :)
+
let $uri := request:get-parameter('uri', '')
let $mdivID := request:get-parameter('mdiv', '')
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, ','), ']')
diff --git a/add/data/xql/getMeasuresOnPage.xql b/add/data/xql/getMeasuresOnPage.xql
index 4be580089..ff4377e6c 100644
--- a/add/data/xql/getMeasuresOnPage.xql
+++ b/add/data/xql/getMeasuresOnPage.xql
@@ -1,62 +1,57 @@
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 .
-
- ID: $Id: getMeasuresOnPage.xql 1273 2012-03-09 16:27:21Z daniel $
-:)
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
(:~
Returns a JSON sequence with all measures on a specific page.
-
+
@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";
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option output:method "json";
declare option output:media-type "application/json";
+(: FUNCTION DECLARATIONS =================================================== :)
+
(:~
Finds all measures on a page.
-
+
@param $mei The sourcefile
@param $surface The surface to look at
@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.
It uses the index and is fast while the second (exact) predicate is generally too slow
:)
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,13 +67,17 @@ 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'))
};
+(: QUERY BODY ============================================================== :)
+
let $uri := request:get-parameter('uri', '')
let $surfaceId := request:get-parameter('pageId', '')
@@ -90,4 +89,4 @@ return (
(: TODO: überlegen, wie die Staff-spezifischen Ausschnitte angezeigt werden sollen :)
local:getMeasures($mei, $surface)
}
-)
\ No newline at end of file
+)
diff --git a/add/data/xql/getMovements.xql b/add/data/xql/getMovements.xql
index 79f04fdc4..190539f2e 100644
--- a/add/data/xql/getMovements.xql
+++ b/add/data/xql/getMovements.xql
@@ -1,57 +1,49 @@
xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: NAMESPACE DECLARATIONS ================================================== :)
- 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 .
-
- 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 xmldb="http://exist-db.org/xquery/xmldb";
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
+
+(: OPTION DECLARATIONS ===================================================== :)
declare option output:method "text";
declare option output:media-type "text/plain";
+(: QUERY BODY ============================================================== :)
+
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),
- 'parts': for $part in $movement//mei:part
- return
- map {
- 'id': $part/string(@xml:id),
- 'name': $part/string(@label)
- }
-
- }
-
-let $array := array { $ret }
+let $ret :=
+ for $movement in $mei//mei:mdiv
+ return
+ map {
+ 'id': $movement/string(@xml:id),
+ 'name': $movement/string(@label),
+ 'parts': for $part in $movement//mei:part
+ return
+ map {
+ 'id': $part/string(@xml:id),
+ 'name': $part/string(@label)
+ }
+
+ }
+
+let $array := array {$ret}
+
let $options :=
map {
'method': 'json',
'media-type': 'text/plain'
}
-
-return serialize($array, $options)
\ No newline at end of file
+
+return
+ serialize($array, $options)
diff --git a/add/data/xql/getMovementsFirstPage.xql b/add/data/xql/getMovementsFirstPage.xql
index 388e48d64..0b316fe6a 100644
--- a/add/data/xql/getMovementsFirstPage.xql
+++ b/add/data/xql/getMovementsFirstPage.xql
@@ -1,41 +1,33 @@
-xquery version "1.0";
+xquery version "3.1";
(:
- Edirom Online
- Copyright (C) 2011 The Edirom Project
- http://www.edirom.de
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
- 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.
+(: NAMESPACE DECLARATIONS ================================================== :)
- 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.
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace xlink = "http://www.w3.org/1999/xlink";
+declare namespace xmldb = "http://exist-db.org/xquery/xmldb";
- You should have received a copy of the GNU General Public License
- along with Edirom Online. If not, see .
-
- 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 xmldb="http://exist-db.org/xquery/xmldb";
+(: OPTION DECLARATIONS ===================================================== :)
declare option exist:serialize "method=text media-type=text/plain omit-xml-declaration=yes";
+(: QUERY BODY ============================================================== :)
+
let $uri := request:get-parameter('uri', '')
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)
diff --git a/add/data/xql/getMusicInMdiv.xql b/add/data/xql/getMusicInMdiv.xql
index d120f8b2b..ab7201028 100644
--- a/add/data/xql/getMusicInMdiv.xql
+++ b/add/data/xql/getMusicInMdiv.xql
@@ -1,23 +1,35 @@
-xquery version "3.0";
+xquery version "3.1";
+(:
+ : For LICENSE-Details please refer to the LICENSE file in the root directory of this repository.
+ :)
-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";
+(: NAMESPACE DECLARATIONS ================================================== :)
+
+declare namespace mei = "http://www.music-encoding.org/ns/mei";
+declare namespace request = "http://exist-db.org/xquery/request";
+declare namespace system = "http://exist-db.org/xquery/system";
+declare namespace transform = "http://exist-db.org/xquery/transform";
+
+(: QUERY BODY ============================================================== :)
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
-
+ (:TODO eventually dynamically use sources @meiversion? :)
+
{$mei//mei:meiHead}
@@ -25,4 +37,4 @@ return
{$data}