Commit 012029e8 authored by mrodzis's avatar mrodzis 🌿
Browse files

Assure all necessary collections are available for ET

parent 362e419d
......@@ -67,8 +67,12 @@ declare function etTransfo:complete() {
:
: @param $uri The notebook's URI, e.g. "16b00" :)
declare function etTransfo:transform-single-nb($uri as xs:string) as xs:string* {
let $assure-dir-available := etTransfo:assure-dir-available("print")
let $assure-dir-available := etTransfo:assure-dir-available("log")
let $log := util:log-system-out("Start creating edited text for " || $uri)
let $log := etTransfo:create-log($uri)
let $tei := doc($config:data-root || "/data/" || $uri || ".xml")//tei:TEI
let $updated-notebook :=
element tei:TEI {
......@@ -107,13 +111,7 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string {
let $log := util:log-system-out("Start creating case " || $showcase || " (" || $doc//tei:title[1] || ").")
let $new-filename := $doc//tei:title[1] => replace(" ", "-") || ".xml"
let $assure-dir-available :=
if(xmldb:collection-available($config:data-root || "/print/")) then
()
else
(xmldb:create-collection($config:data-root, "/print"),
xmldb:create-collection($config:data-root || "/print/", "xml"),
xmldb:create-collection($config:data-root || "/print/", "xhtml"))
let $assure-dir-available := etTransfo:assure-dir-available("print")
let $create-new-file := xmldb:store($config:data-root || "/print/xml/", $new-filename, $doc/*)
......@@ -390,14 +388,25 @@ declare function etTransfo:create-log($uri as xs:string) as xs:string {
declare function etTransfo:assure-dir-available($dir-name as xs:string) {
if(xmldb:collection-available($etTransfo:dir || "logs")) then
$etTransfo:dir || "logs"
else
xmldb:create-collection($etTransfo:dir, "logs")
switch ($dir-name)
case "log" return
if(xmldb:collection-available($etTransfo:dir || "logs")) then
$etTransfo:dir || "logs"
else
xmldb:create-collection($etTransfo:dir, "logs")
};
case "print" return
if(xmldb:collection-available($config:data-root || "/print/")) then
()
else
(xmldb:create-collection($config:data-root, "/print"),
xmldb:create-collection($config:data-root || "/print/", "xml"),
xmldb:create-collection($config:data-root || "/print/", "xhtml"))
default return ()
};
declare function etTransfo:add-log-entry($log-file as xs:string,
$message as xs:string) as empty-sequence() {
let $entry := <LogEntry timestamp="{util:system-time()}">{$message}</LogEntry>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment