From 40cc2068f17060996f2da2dd92627e4ef24b5149 Mon Sep 17 00:00:00 2001 From: MRodz <rodzis@sub.uni-goettingen.de> Date: Wed, 26 Sep 2018 15:02:06 +0200 Subject: [PATCH] Add logging for debugging --- modules/intermediate_format/ifweb.xql | 11 +++++++++++ modules/intermediate_format/preprocessing.xqm | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/intermediate_format/ifweb.xql b/modules/intermediate_format/ifweb.xql index 751526c..94dd040 100644 --- a/modules/intermediate_format/ifweb.xql +++ b/modules/intermediate_format/ifweb.xql @@ -12,6 +12,7 @@ module namespace ifweb="http://bdn-edition.de/intermediate_format/ifweb"; declare namespace tei = "http://www.tei-c.org/ns/1.0"; +import module namespace console="http://exist-db.org/xquery/console"; import module namespace pre="http://bdn-edition.de/intermediate_format/preprocessing" at "xmldb:exist:///db/apps/interformat/modules/intermediate_format/preprocessing.xqm"; import module namespace ident = "http://bdn-edition.de/intermediate_format/identification" at "xmldb:exist:///db/apps/interformat/modules/intermediate_format/identification.xqm"; import module namespace config = "http://bdn-edition.de/intermediate_format/config" at "xmldb:exist:///db/apps/interformat/modules/config.xqm"; @@ -30,7 +31,9 @@ declare function ifweb:main($resource as xs:string) as xs:string? { declare function ifweb:transform($doc as node()*, $filename as xs:string) as node()* { let $replace-whitespace := true() + let $log := console:log("Start preprocessing.") let $preprocessed-data := pre:preprocessing($doc/tei:TEI, $replace-whitespace) + let $log := console:log("Start main processing.") let $intermediate-format := ident:walk($preprocessed-data, ()) let $store := xmldb:store($config:sade-data, $filename, $intermediate-format) @@ -39,6 +42,14 @@ as node()* { declare function ifweb:complete-xml($author as xs:string, $xml as node()*) as node()* { + let $log-dir := + if(xmldb:collection-available($config:app-root || "/logs")) then + $config:app-root || "/logs" + else + xmldb:create-collection($config:app-root, "logs") + let $log-name := "log.xml" + let $create := xmldb:store($log-dir, $log-name, <root/>) + let $filename := $author || "-full-if.xml" return ifweb:transform($xml, $filename) }; diff --git a/modules/intermediate_format/preprocessing.xqm b/modules/intermediate_format/preprocessing.xqm index 46e87c1..da7fad3 100644 --- a/modules/intermediate_format/preprocessing.xqm +++ b/modules/intermediate_format/preprocessing.xqm @@ -12,6 +12,7 @@ xquery version "3.0"; :) module namespace pre="http://bdn-edition.de/intermediate_format/preprocessing"; import module namespace whitespace = "http://bdn-edition.de/intermediate_format/whitespace_handling" at "whitespace-handling.xqm"; +import module namespace console="http://exist-db.org/xquery/console"; declare default element namespace "http://www.tei-c.org/ns/1.0"; @@ -109,7 +110,7 @@ declare function pre:default-element let $following-node := $node/following-sibling::node()[1] let $following-sibling := $node/following-sibling::*[1] return - element{$node/name()}{ + (element{$node/name()}{ $node/@*, (if($following-node[matches(., "[\s\n\r\t]") and normalize-space(.) = ""] and $following-sibling[self::ref or self::app or self::hi or self::bibl @@ -121,7 +122,9 @@ declare function pre:default-element attribute {"break-after"}{"yes"} else ()), $recursive-function - } + }, + update insert $node into doc("/db/apps/interformat/logs/log.xml")/* + ) }; -- GitLab