Skip to content

Commit c26bf4a

Browse files
committed
add documentation to db_switcg_build.xqm
1 parent a5c7a6a commit c26bf4a

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

repo/backend/db_switch_build.xqm

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
xquery version "3.1";
1+
xquery version "4.0";
22

33
(:~
44
: Ce module permet d'initialiser la base de données "dots" et y ajoute les deux documents XML: "dots_db_switcher.xml" et "dots_default_metadata_mapping.xml".
@@ -15,33 +15,42 @@ xquery version "3.1";
1515
: @since 2023-06-14
1616
: @version 1.0
1717
:)
18+
(:~
19+
: Module to initialize the "dots" database with two XML documents:
20+
: "dots_db_switcher.xml": lists available resources and specifies:
21+
: - the resource type ("project", "collection", or "document"),
22+
: - its unique identifier (@dtsResourceId),
23+
: - and the corresponding BaseX database (@dbName).
24+
: Initially empty, this file is later populated with resource entries.
25+
: It is used by the DTS router to locate metadata for each resource.
26+
:
27+
: "dots_default_metadata_mapping.xml": default metadata mapping applied when no custom mapping is available. It extracts key metadata (title, creator, publisher) using XPath expressions.
28+
:
29+
: Author: École nationale des chartes
30+
: Since: 2023-06-14
31+
: Version: 1.0
32+
:)
1833
module namespace dots.build = "backend/db_switch_build";
1934

2035
import module namespace G = "globals";
2136

2237
declare default element namespace "https://github.com/chartes/dots/";
2338
declare namespace dct = "http://purl.org/dc/terms/";
2439

25-
(:~
26-
: Cette fonction permet d'ajouter ou modifier les deux documents XML de la db dots.
27-
: @return 2 documents XML à ajouter à la db "dots"
28-
: @param $G:dots chaîne de caractère, variable globale pour accéder à la db dots
29-
: @param $dbName chaîne de caractère qui donne le nom de la db
30-
: @param $topCollectionId chaîne de caractère correspondant à l'identifiant du projet (qui peut être différent du nom de la db)
31-
: @see db_switch_builder.xqm;db.switcher:getTopCollection
32-
: @see db_switch_builder.xqm;db.switcher:members
33-
: @see db_switch_builder.xqm;db.switcher:getHeaders
40+
(:~
41+
: Creates or updates the two XML documents in the "dots" database.
42+
: @return The two documents to be added to the "dots" database.
3443
:)
3544
declare updating function dots.build:dots_db() {
3645
let $dbSwitch := dots.build:switcher()
3746
let $metadataMap := dots.build:metadataMap()
3847
return db:create($G:dots, ($dbSwitch, $metadataMap), ($G:dbSwitcher, $G:metadataMapping))
3948
};
4049

41-
(:~
42-
: Cette fonction prépare l'en-tête des deux documents XML à créer pour la db dots
43-
: @return élément XML <metadata></metadata> avec son contenu
44-
: @param $option chaîne de caractère pour savoir si l'élément <totalProject/> doit être intégré au header
50+
(:~
51+
: Generates the <metadata> header for each XML document.
52+
: @param $option a string flag to indicate if the <totalProjects/> tag should be added.
53+
: @return a <metadata> element with creation and modification timestamps.
4554
:)
4655
declare %private function dots.build:headers($option as xs:string) {
4756
<metadata>
@@ -51,13 +60,21 @@ declare %private function dots.build:headers($option as xs:string) {
5160
</metadata>
5261
};
5362

63+
(:~
64+
: Creates the initial, "dots_db_switcher.xml" document.
65+
: @return a <dbSwitch/> element, with <metadata/> and empty <member/> childs.
66+
:)
5467
declare %private function dots.build:switcher() {
5568
<dbSwitch xmlns="https://github.com/chartes/dots/">{
5669
dots.build:headers("dbSwitch"),
5770
<member/>
5871
}</dbSwitch>
5972
};
6073

74+
(:~
75+
: Creates the "dots_default_metadata_mapping.xml" document.
76+
: @return a <metadataMap/> element with XPath-based mappings for title, creator, and publisher metadata.
77+
:)
6178
declare %private function dots.build:metadataMap() {
6279
<metadataMap xmlns="https://github.com/chartes/dots/" xmlns:dc="http://purl.org/dc/elements/1.1/"
6380
xmlns:dct="http://purl.org/dc/terms/">{

0 commit comments

Comments
 (0)