From aa2dabc2fad39d27aabeff05ae5876c8017b8bab Mon Sep 17 00:00:00 2001
From: Peter Stadler
Date: Thu, 7 Dec 2023 15:58:20 +0100
Subject: [PATCH 1/6] update database variable
and update output options
---
modules/tools/batch_transform.xq | 10 ++++++----
modules/tools/batch_transform_list.xq | 8 +++++---
modules/tools/batch_transform_settings.xq | 4 +++-
modules/tools/list_incipit_graphics.xq | 8 ++++++--
modules/tools/list_source_provenance.xq | 8 ++++++--
modules/tools/list_text_incipits.xq | 8 ++++++--
modules/tools/location_index.xq | 10 +++++++---
modules/tools/name_index.xq | 8 ++++++--
modules/tools/name_index_step1.xq | 8 ++++++--
modules/tools/name_index_step2.xq | 8 ++++++--
modules/tools/opus_index.xq | 8 ++++++--
modules/tools/performance_city_index.xq | 8 ++++++--
modules/tools/provenance_index.xq | 8 ++++++--
modules/tools/select.xq | 10 ++++++----
modules/tools/select_generator.xq | 10 ++++++----
modules/tools/select_generator_cnw.xq | 8 ++++++--
modules/tools/text_author_index.xq | 8 ++++++--
modules/tools/title_index.xq | 8 ++++++--
18 files changed, 105 insertions(+), 43 deletions(-)
diff --git a/modules/tools/batch_transform.xq b/modules/tools/batch_transform.xq
index f6d530c7..31dd4ac0 100644
--- a/modules/tools/batch_transform.xq
+++ b/modules/tools/batch_transform.xq
@@ -1,8 +1,5 @@
xquery version "1.0" encoding "UTF-8";
-import module namespace login="http://kb.dk/this/login" at "../login.xqm";
-import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-
declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace transform="http://exist-db.org/xquery/transform";
@@ -12,11 +9,16 @@ declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
declare namespace xdb="http://exist-db.org/xquery/xmldb";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace login="http://kb.dk/this/login" at "../login.xqm";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
+
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
declare variable $coll := request:get-parameter("coll", "") cast as xs:string;
declare variable $query := request:get-parameter("query","") cast as xs:string;
diff --git a/modules/tools/batch_transform_list.xq b/modules/tools/batch_transform_list.xq
index c37d01ee..b4bc56dd 100644
--- a/modules/tools/batch_transform_list.xq
+++ b/modules/tools/batch_transform_list.xq
@@ -1,7 +1,5 @@
xquery version "1.0" encoding "UTF-8";
-import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-
declare namespace xl="http://www.w3.org/1999/xlink";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
@@ -10,11 +8,15 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
+
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
declare variable $coll := request:get-parameter("coll","") cast as xs:string;
declare variable $query := request:get-parameter("query","") cast as xs:string;
diff --git a/modules/tools/batch_transform_settings.xq b/modules/tools/batch_transform_settings.xq
index 16689bc9..9fb93c3a 100644
--- a/modules/tools/batch_transform_settings.xq
+++ b/modules/tools/batch_transform_settings.xq
@@ -1,10 +1,12 @@
xquery version "1.0" encoding "UTF-8";
declare namespace request="http://exist-db.org/xquery/request";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare option exist:serialize "method=xml media-type=text/html;charset=UTF-8";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
declare variable $coll := request:get-parameter("coll", "") cast as xs:string;
declare variable $query := request:get-parameter("query","") cast as xs:string;
diff --git a/modules/tools/list_incipit_graphics.xq b/modules/tools/list_incipit_graphics.xq
index c045174c..8c5bb4fd 100644
--- a/modules/tools/list_incipit_graphics.xq
+++ b/modules/tools/list_incipit_graphics.xq
@@ -9,13 +9,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
(: desired resolution; MerMEId supports values "lowres", "hires", and "print" :)
declare variable $resolution := request:get-parameter("res","lowres");
diff --git a/modules/tools/list_source_provenance.xq b/modules/tools/list_source_provenance.xq
index 12cb5bc6..7c3ad9e8 100644
--- a/modules/tools/list_source_provenance.xq
+++ b/modules/tools/list_source_provenance.xq
@@ -9,13 +9,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
diff --git a/modules/tools/list_text_incipits.xq b/modules/tools/list_text_incipits.xq
index 66280718..a8889e7c 100644
--- a/modules/tools/list_text_incipits.xq
+++ b/modules/tools/list_text_incipits.xq
@@ -9,13 +9,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
(: desired resolution; MerMEId supports values "lowres", "hires", and "print" :)
declare variable $resolution := "lowres";
diff --git a/modules/tools/location_index.xq b/modules/tools/location_index.xq
index 0f02dad1..5d1f925e 100644
--- a/modules/tools/location_index.xq
+++ b/modules/tools/location_index.xq
@@ -10,14 +10,18 @@ declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
declare namespace marc="http://www.loc.gov/MARC21/slim";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
-declare variable $rism_dir := "/db/rism_sigla";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
+declare variable $rism_dir := $config:app-root || "/rism_sigla";
declare variable $country_codes := doc(concat($rism_dir,'/RISM_country_codes.xml'));
declare variable $collection := request:get-parameter("c","");
diff --git a/modules/tools/name_index.xq b/modules/tools/name_index.xq
index 2d893ea9..7b56240d 100644
--- a/modules/tools/name_index.xq
+++ b/modules/tools/name_index.xq
@@ -11,13 +11,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
diff --git a/modules/tools/name_index_step1.xq b/modules/tools/name_index_step1.xq
index fbc8c586..77a141d9 100644
--- a/modules/tools/name_index_step1.xq
+++ b/modules/tools/name_index_step1.xq
@@ -9,13 +9,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
diff --git a/modules/tools/name_index_step2.xq b/modules/tools/name_index_step2.xq
index 85d95567..f756ac02 100644
--- a/modules/tools/name_index_step2.xq
+++ b/modules/tools/name_index_step2.xq
@@ -11,13 +11,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
declare variable $names :=
diff --git a/modules/tools/opus_index.xq b/modules/tools/opus_index.xq
index 379b7752..745d11bf 100644
--- a/modules/tools/opus_index.xq
+++ b/modules/tools/opus_index.xq
@@ -7,13 +7,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
(: the separator used for opus sub-numbers, e.g. Opus 27:2 :)
declare variable $separator := request:get-parameter("separator",":");
diff --git a/modules/tools/performance_city_index.xq b/modules/tools/performance_city_index.xq
index 8af9889c..c475da18 100644
--- a/modules/tools/performance_city_index.xq
+++ b/modules/tools/performance_city_index.xq
@@ -10,13 +10,17 @@ declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
declare namespace marc="http://www.loc.gov/MARC21/slim";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
diff --git a/modules/tools/provenance_index.xq b/modules/tools/provenance_index.xq
index d916e152..44ab9aaa 100644
--- a/modules/tools/provenance_index.xq
+++ b/modules/tools/provenance_index.xq
@@ -11,13 +11,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
declare variable $invert := request:get-parameter("invert","false");
diff --git a/modules/tools/select.xq b/modules/tools/select.xq
index 1d9361fb..681801f6 100644
--- a/modules/tools/select.xq
+++ b/modules/tools/select.xq
@@ -5,8 +5,6 @@ xquery version "1.0" encoding "UTF-8";
declare namespace loop="http://kb.dk/this/getlist";
-import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-
declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace fn="http://www.w3.org/2005/xpath-functions";
@@ -14,13 +12,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
+
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
-declare variable $database := $config:data-public-root;
+declare variable $database := $config:data-root;
declare variable $coll := request:get-parameter("c","HartW");
diff --git a/modules/tools/select_generator.xq b/modules/tools/select_generator.xq
index 96303789..15508659 100644
--- a/modules/tools/select_generator.xq
+++ b/modules/tools/select_generator.xq
@@ -3,8 +3,6 @@ xquery version "1.0" encoding "UTF-8";
(: A script to generate select boxes for searching by keys such as opus numbers numbers or names. :)
(: The generated code needs to be cleaned manually, though :)
-import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-
declare namespace loop="http://kb.dk/this/getlist";
declare namespace request="http://exist-db.org/xquery/request";
@@ -14,13 +12,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
+
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
-declare variable $database := $config:data-public-root;
+declare variable $database := $config:data-root;
declare variable $coll := request:get-parameter("c","HartW");
diff --git a/modules/tools/select_generator_cnw.xq b/modules/tools/select_generator_cnw.xq
index c7112ca4..208b429e 100644
--- a/modules/tools/select_generator_cnw.xq
+++ b/modules/tools/select_generator_cnw.xq
@@ -12,13 +12,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/cnw/data";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare function loop:clean-names ($key as xs:string) as xs:string
diff --git a/modules/tools/text_author_index.xq b/modules/tools/text_author_index.xq
index 43db6c09..bf9f785b 100644
--- a/modules/tools/text_author_index.xq
+++ b/modules/tools/text_author_index.xq
@@ -11,13 +11,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
diff --git a/modules/tools/title_index.xq b/modules/tools/title_index.xq
index fa1fa085..4ace93ad 100644
--- a/modules/tools/title_index.xq
+++ b/modules/tools/title_index.xq
@@ -7,13 +7,17 @@ declare namespace file="http://exist-db.org/xquery/file";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare namespace ht="http://exist-db.org/xquery/httpclient";
+declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace local="http://kb.dk/this/app";
declare namespace m="http://www.music-encoding.org/ns/mei";
-declare option exist:serialize "method=xml media-type=text/html";
+import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
-declare variable $database := "/db/dcm";
+declare option output:method "xhtml5";
+declare option output:media-type "text/html";
+
+declare variable $database := $config:data-root;
declare variable $collection := request:get-parameter("c","");
From 437fee7cbf8ca784018787c5eeff6a3ac52573e5 Mon Sep 17 00:00:00 2001
From: Peter Stadler
Date: Thu, 4 Jan 2024 13:52:20 +0100
Subject: [PATCH 2/6] fix XQuery declaration
---
modules/tools/location_index.xq | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/tools/location_index.xq b/modules/tools/location_index.xq
index 5d1f925e..22adf419 100644
--- a/modules/tools/location_index.xq
+++ b/modules/tools/location_index.xq
@@ -1,4 +1,4 @@
-xquery version "1.0" encoding "UTF-8";
+xquery version "3.1" encoding "UTF-8";
declare namespace loop="http://kb.dk/this/getlist";
From 4618afd1cbf27e8b4a34c65cff926f332e37ed5a Mon Sep 17 00:00:00 2001
From: Peter Stadler
Date: Thu, 4 Jan 2024 13:53:27 +0100
Subject: [PATCH 3/6] update documentation
added URL parameter to all queries and fixed the example link
---
manual/index_tools.html | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/manual/index_tools.html b/manual/index_tools.html
index a99b3fe3..56b1f260 100644
--- a/manual/index_tools.html
+++ b/manual/index_tools.html
@@ -25,7 +25,7 @@ Tools for generating indexes
All of the tools described below are located in the 'tools' folder of your eXist
database. In order to generate any output they need a query parameter named 'c'
added to the URL to specify which file collection to generate an index for (for
- instance: http://my_server_name.org/storage/tools/title_index?c=CNW ).
+ instance: http://localhost:8080/modules/tools/title_index.xq?c=Demo
).
The lists generated are meant as a starting point for an index. Most likely you will
need to make manual corrections.
If you want to change the default formatting such as the use of italics, you may want
@@ -40,7 +40,7 @@
Tools for generating indexes
Title index
To generate a simple list of titles, alphabetically ordered, use the title_index.xq script located in the
+ href="../modules/tools/title_index.xq?c=Demo">title_index.xq script located in the
'tools' folder of your eXist database.
The script generates a list in two sections: First a list of main titles with
subtitles and (in parentheses) alternative titles. Below that, it generates a list
@@ -49,7 +49,7 @@
Tools for generating indexes
Index of names
- The script name_index.xq produces a list
+
The script name_index.xq produces a list
of all names encoded as <persName> elements within the <sourceDesc> and
<workList> elements. This restriction ensures that persons such as the encoder
or project manager (usually encoded in <fileDesc>) are not included.
@@ -59,41 +59,41 @@ Tools for generating indexes
entire database several times. If you experience a server timeout when running
it, you may want to try a two-step approach instead. However, this solution
involves editing one of the scripts on the server. First, use the script name_index_step1.xq to
+ href="../modules/tools/name_index_step1.xq?c=Demo">name_index_step1.xq to
generate a list of all the persons found. This list is pasted into the source
code of the second script (the code indicates where), name_index_step2.xq, which in
+ href="../modules/tools/name_index_step2.xq?c=Demo">name_index_step2.xq, which in
turn searches for alle occurrences of each name on the list.
Index of text authors
- The index of text authors, The index of text authors, text_author_index.xq, is a just subset of the general index of names, only
including the <persName> elements having @role='author'. This index is
intended to list the authors of vocal text (lyrics) only; it does not include
authors of documentary material or literature such as letters, articles and books,
which MerMEId defines using the <author> element.
- Index of opus numbers
The script Index of opus numbers The script opus_index.xq lists the titles of works having an identifier named 'Opus' at
the 'Work' tab:
Index of performance locations
- A list of performance places (cities) is generated by the performance_city_index.xq script.
+
A list of performance places (cities) is generated by the performance_city_index.xq script.
Index of item (source) locations
- The script location_index.xq generates
+
The script location_index.xq generates
a list of the locations of items (that is, manuscripts or specific copies of printed
sources).
The script tries to resolve RISM sigla; locations not recognizable
as RISM sigla are reproduced as written.
List of incipit graphics
For proofreading incipits added as graphics (images), a tool list_incipit_graphics.xq is
+ href="../modules/tools/list_incipit_graphics.xq?c=Demo">list_incipit_graphics.xq is
available to output all graphics including the movement titles and file URLs. The
script does not (yet) include incipits to be rendered at runtime.
From 0672ad40078ed9ad549e72bcd1dab802e0972132 Mon Sep 17 00:00:00 2001
From: Peter Stadler
Date: Thu, 4 Jan 2024 13:54:05 +0100
Subject: [PATCH 4/6] add workaround for relative graphic URLs
---
modules/tools/list_incipit_graphics.xq | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/modules/tools/list_incipit_graphics.xq b/modules/tools/list_incipit_graphics.xq
index 8c5bb4fd..9425c8f9 100644
--- a/modules/tools/list_incipit_graphics.xq
+++ b/modules/tools/list_incipit_graphics.xq
@@ -1,4 +1,4 @@
-xquery version "1.0" encoding "UTF-8";
+xquery version "3.1" encoding "UTF-8";
(: Generates a list of incipits graphic files ordered by work (catalogue) number :)
@@ -61,15 +61,21 @@ declare function local:movement($expression) as node()
{local:movement-title($expression)}
{
for $img at $pos in $expression/m:incip/m:graphic[@targettype=$resolution and @target!='']
+ let $img.graphic.target := $expression/m:incip/m:graphic[@targettype=$resolution][$pos]/@target
+ let $img.src :=
+ (: special treatment for relative links :)
+ if(starts-with($img.graphic.target, 'http') or starts-with($img.graphic.target, '//'))
+ then $img.graphic.target => string()
+ else $config:exist-endpoint || '/data/' || $img.graphic.target
return
{
element img {
- attribute src {$expression/m:incip/m:graphic[@targettype=$resolution][$pos]/@target}
+ attribute src {$img.src}
}
}
- {string($expression/m:incip/m:graphic[@targettype=$resolution][$pos]/@target)}
+ {$img.graphic.target => string()}
}
{
From 167618c050f87b9cd143df9b3a7274bbfae2f232 Mon Sep 17 00:00:00 2001
From: Peter Stadler
Date: Thu, 4 Jan 2024 17:55:34 +0100
Subject: [PATCH 5/6] fix and improve query
which was failing with "HTTP ERROR 500 javax.servlet.ServletException: javax.servlet.ServletException: An error occurred while processing request to /modules/tools/location_index.xq: An error occurred: class org.exist.xquery.value.ValueSequence cannot be cast to class org.exist.dom.persistent.NodeSet (org.exist.xquery.value.ValueSequence and org.exist.dom.persistent.NodeSet are in unnamed module of loader 'app')"
---
modules/tools/location_index.xq | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/modules/tools/location_index.xq b/modules/tools/location_index.xq
index 22adf419..21c51590 100644
--- a/modules/tools/location_index.xq
+++ b/modules/tools/location_index.xq
@@ -5,14 +5,14 @@ declare namespace loop="http://kb.dk/this/getlist";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace fn="http://www.w3.org/2005/xpath-functions";
-declare namespace file="http://exist-db.org/xquery/file";
-declare namespace util="http://exist-db.org/xquery/util";
-declare namespace ft="http://exist-db.org/xquery/lucene";
-declare namespace ht="http://exist-db.org/xquery/httpclient";
+(:declare namespace file="http://exist-db.org/xquery/file";:)
+(:declare namespace util="http://exist-db.org/xquery/util";:)
+(:declare namespace ft="http://exist-db.org/xquery/lucene";:)
+(:declare namespace ht="http://exist-db.org/xquery/httpclient";:)
declare namespace marc="http://www.loc.gov/MARC21/slim";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
-declare namespace local="http://kb.dk/this/app";
+(:declare namespace local="http://kb.dk/this/app";:)
declare namespace m="http://www.music-encoding.org/ns/mei";
import module namespace config="https://github.com/edirom/mermeid/config" at "../config.xqm";
@@ -44,7 +44,6 @@ declare function loop:sort-key ($identifier as xs:string) as xs:string
declare function loop:lookup ($location as xs:string) as xs:string
{
let $country_code:=substring-before($location,'-')
- let $filename:=concat($country_code,'.xml')
let $txt:=
if($country_codes/m:list/m:li/m:geogName[@codedval=$country_code])
then
@@ -86,24 +85,23 @@ declare function loop:lookup-archive ($location as xs:string, $country_code as x
Please choose a file collection/catalogue by adding '?c=[your collection name]'
(for instance, ?c=CNW) to the URL
else
- for $c in distinct-values(
+ for $c in
collection($database)/m:mei/m:meiHead[m:fileDesc/m:seriesStmt/m:identifier[@type="file_collection"] = $collection]/
m:manifestationList/m:manifestation//m:physLoc/m:repository/
- (m:identifier[@authority='RISM' and normalize-space(.)] | m:corpName[normalize-space(.)]) )
- order by normalize-space(string($c))
+ (m:identifier[@auth='RISM' and normalize-space(.)] | m:corpName[normalize-space(.)])
+ group by $ident := normalize-space($c)
+ order by loop:lookup($ident)
return
- {concat(loop:lookup($c),' ',$collection,' ')}
+ {concat(loop:lookup($ident),' ',$collection,' ')}
{let $numbers :=
- for $n in collection($database)/m:mei/m:meiHead[m:fileDesc/m:seriesStmt/m:identifier[@type="file_collection"] = $collection]
- where $n/m:manifestationList/m:manifestation//m:physLoc/m:repository/
- (m:identifier[@authority='RISM' and normalize-space(.)] | m:corpName[normalize-space(.)]) = $c
- order by loop:sort-key($n/m:workList/m:work/m:identifier[@label=$collection]/string())
- return $n/m:workList/m:work/m:identifier[@label=$collection]/string()
+ for $n in $c
+ let $number := $n/ancestor::m:meiHead/m:workList/m:work/m:identifier[@label=$collection] => normalize-space()
+ order by loop:sort-key($number)
+ return $number
return string-join($numbers,', ')
}
-
}
From 3d677beebf4096159439207c423722bb8ae5d3e5 Mon Sep 17 00:00:00 2001
From: Peter Stadler
Date: Mon, 15 Jan 2024 22:10:06 +0100
Subject: [PATCH 6/6] apply improvement provided by @peterprovaznik
---
modules/tools/location_index.xq | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/tools/location_index.xq b/modules/tools/location_index.xq
index 21c51590..0e20a297 100644
--- a/modules/tools/location_index.xq
+++ b/modules/tools/location_index.xq
@@ -99,7 +99,7 @@ declare function loop:lookup-archive ($location as xs:string, $country_code as x
let $number := $n/ancestor::m:meiHead/m:workList/m:work/m:identifier[@label=$collection] => normalize-space()
order by loop:sort-key($number)
return $number
- return string-join($numbers,', ')
+ return $numbers => distinct-values() => string-join(', ')
}
}