From 607d1a544204dd8250cdadf80a610597621de874 Mon Sep 17 00:00:00 2001 From: Michelle Weidling <weidling@sub.uni-goettingen.de> Date: Mon, 11 Feb 2019 16:46:05 +0100 Subject: [PATCH] Closes bdn-SADE#45 --- modules/intermediate_format/ifweb.xql | 4 +++- modules/intermediate_format/preprocessing.xqm | 23 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/intermediate_format/ifweb.xql b/modules/intermediate_format/ifweb.xql index efb955f..356dad3 100644 --- a/modules/intermediate_format/ifweb.xql +++ b/modules/intermediate_format/ifweb.xql @@ -64,6 +64,7 @@ $target-dir as xs:string) as node()* { declare function ifweb:transform-split-xml($xml as node()*, $filename as xs:string, $dir as xs:string) { let $preprocessed-data := pre:preprocessing($xml/*, $ifweb:replace-whitespace) + let $editorial-notes := pre:get-editorial-notes($xml/*, $ifweb:replace-whitespace) let $intermediate-format := ident:walk($preprocessed-data, ()) (: sometimes we have structural variance on chapter level - in these cases @@ -84,7 +85,8 @@ $dir as xs:string) { let $transformed := element tei:div { - $content + $content, + $editorial-notes } let $store := xmldb:store($dir, $filename, $transformed) diff --git a/modules/intermediate_format/preprocessing.xqm b/modules/intermediate_format/preprocessing.xqm index 54c89ac..25b6c4c 100644 --- a/modules/intermediate_format/preprocessing.xqm +++ b/modules/intermediate_format/preprocessing.xqm @@ -51,9 +51,7 @@ declare function pre:preprocessing-textNode element{$node/name()}{ $node/@*, pre:preprocessing-textNode($node/node()), - element{"editorial-notes"}{ - $node//note[@type eq "editorial-commentary"] - } + pre:get-editorial-notes($node, $replace-whitespace) } ) @@ -166,11 +164,7 @@ declare function pre:preprocessing element{$node/name()}{ $node/@*, pre:preprocessing($node/node(), $replace-whitespace), - element{"editorial-notes"}{ - for $editorial-note in $node//note[@type eq "editorial-commentary"] - return - pre:default-element( $editorial-note, pre:preprocessing($editorial-note/node(), $replace-whitespace) ) - } + pre:get-editorial-notes($node, $replace-whitespace) } ) @@ -312,3 +306,16 @@ declare function pre:preprocessing pre:default-element( $node, pre:preprocessing($node/node(), $replace-whitespace) ) ) }; + +(:~ + : Returns all editorial notes of a document in a new element. + : + : @author Michelle Weidling :) +declare function pre:get-editorial-notes($node as node()*, $replace-whitespace) +as element(editorial-notes) { + element{"editorial-notes"}{ + for $editorial-note in $node//note[@type eq "editorial-commentary"] + return + pre:default-element($editorial-note, pre:preprocessing($editorial-note/node(), $replace-whitespace)) + } +}; -- GitLab