From 20f36fa47a5b74ca2468852a175a68cd873624c5 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Wed, 31 Jul 2019 13:16:05 +0200 Subject: [PATCH 01/97] Properly display glued pages (3.6) --- modules/fontane/edited-text/tei2teisimple.xqm | 5 ++--- modules/fontane/edited-text/tidysimple.xqm | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index d00add0d..ae5fc279 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -418,10 +418,9 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if(not($node/@subtype = "Kalenderblatt" - or $node/@subtype = "Zeitungsausschnitt_Fragment")) then + else if(not($node/@subtype = "Kalenderblatt")) then element tei:div { - $node/(@* except (@n, @ulx, @uly, @lry, @lrx)), + $node/(@* except (@n, @ulx, @uly, @lry, @lrx, @facs)), fontaneSimple:transform($node/node(), $uri, $log) } diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 1885ed14..f4aa7ce5 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -93,7 +93,8 @@ as node()* { calendar pages by Friedrich Fontane. Unfortunately, Friedrich's handshift is oftentimes not the first hand appearing on the page but we want to keep the page nevertheless. :) - if($node/@type = "Kalenderblatt") then + if($node/@type = "Kalenderblatt" + or $node/@type = "clipping") then tidySimple:copy-element($node, "post") else tidySimple:invalid-hands-default-return($node) @@ -139,8 +140,8 @@ as node()* { case element(tei:milestone) return if($node/@unit = "handshift") then - if(simpleHelpers:is-prev-hand-same($node) - or not(tidySimple:has-hand-text($node))) then + if( + simpleHelpers:is-prev-hand-same($node)) then () else element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { -- GitLab From e007f01faf2af167a7dbc524bfc5bad4562d755f Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Wed, 7 Aug 2019 14:22:14 +0200 Subject: [PATCH 02/97] Implement images that span over two pages --- modules/fontane/edited-text/simple2xhtml.xqm | 77 +++++++--- modules/fontane/edited-text/tei2teisimple.xqm | 139 ++++++++++-------- modules/fontane/edited-text/tidysimple.xqm | 31 ++++ 3 files changed, 165 insertions(+), 82 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 15e454b7..b573e5ae 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -315,31 +315,58 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) case element(tei:figure) return - let $captions-before := - $node/preceding-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] - let $captions-after := - $node/following-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] - return - (: make captions left of sketch:) - (if(exists($captions-before)) then - simple2xhtml:make-img-captions($captions-before, "right-aligned") - else - (), + if(not($node/ancestor::tei:ab/preceding-sibling::*[1][descendant::tei:figure[@type = "double"]])) then + let $captions-before := + $node/preceding-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] + let $captions-after := + $node/following-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] + return + (: make captions left of sketch:) + (if(exists($captions-before)) then + simple2xhtml:make-img-captions($captions-before, "right-aligned") + else + (), + + (: for an ordinary img or the left part of a double img :) + element xhtml:td { + if($node/@type = "double") then + attribute class {"nb-double-img"} + else + attribute class {"nb-img"}, + if($node/@rotate) then + attribute style {concat("width: ", $node/parent::*/@height, "; height: ", $node/parent::*/@width, ";")} + else + (), + if($node/@type = "double") then + simple2xhtml:make-img($node, "double") + else + simple2xhtml:make-img($node, "block") + }, + + if($node/@type = "double" + and $node/ancestor::tei:ab/following-sibling::*[1][descendant::tei:figure[@type = "double"]]) then + let $next-node := $node/ancestor::tei:ab/following-sibling::*[1]/descendant::tei:figure[@type = "double"] + return + element xhtml:td { + attribute class {"nb-double-img"}, + if($next-node/@rotate) then + attribute style {concat("width: ", $next-node/parent::*/@height, "; height: ", $next-node/parent::*/@width, ";")} + else + (), + simple2xhtml:make-img($next-node, "double") + } - element xhtml:td { - attribute class {"nb-img"}, - if($node/@rotate) then - attribute style {concat("width: ", $node/parent::*/@height, "; height: ", $node/parent::*/@width, ";")} else (), - simple2xhtml:make-img($node, "block") - }, - (: make captions right of sketch:) - if(exists($captions-after)) then - simple2xhtml:make-img-captions($captions-after, "left-aligned") + (: make captions right of sketch:) + if(exists($captions-after)) then + simple2xhtml:make-img-captions($captions-after, "left-aligned") + else + ()) + (: right parts of sketches on double pages are processed when processing the left part :) else - ()) + () case element(tei:seg) return if($node/@type = ("caption", "editorial-label", "multiphrase")) then @@ -484,11 +511,15 @@ $mode as xs:string) as element(xhtml:img) { return element xhtml:img { + if($node/@id) then + attribute id {$node/@id} + else + (), attribute src {$node/@href}, attribute alt {$node//tei:figDesc/string()}, -(: if($mode = "block") then:) -(: attribute class {"nb-block-img"}:) -(: else:) + if($mode = "double") then + attribute class {"nb-double-img"} + else attribute class {"nb-block-img"}, attribute style {$width || $height || $rotation} } diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index ae5fc279..6c944830 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -401,15 +401,13 @@ $log as xs:string) as node()* { } else if($node/@type = "pocket") then - (fontaneSimple:make-pb($node), element tei:div{ $node/(@* except (@n, @ulx, @uly, @lry, @lrx)), fontaneSimple:transform($node/node(), $uri, $log) - }) + } else if(simpleHelpers:is-page($node) and $node/@type = "clipping") then - (fontaneSimple:make-pb($node), (if($node/@subtype = "Kalenderblatt" and contains($node//tei:handShift/@new, "Friedrich_Fontane")) then element tei:div { @@ -425,11 +423,10 @@ $log as xs:string) as node()* { } else - ())) + ()) else if(simpleHelpers:is-page($node)) then - (fontaneSimple:make-pb($node), - fontaneSimple:transform($node/node(), $uri, $log)) + fontaneSimple:transform($node/node(), $uri, $log) else if($node/@type = "label" and (contains($node/@subtype, "Fontane") @@ -512,6 +509,14 @@ $log as xs:string) as node()* { if($node/parent::tei:zone[@type = "illustration"]) then attribute rendition {"margin-left:" || $node/@ulx || "cm; " || "margin-top:" || $node/@uly || "cm"} + else + (), + if($node/ancestor::tei:surface/@next) then + (attribute xml:id {$node/ancestor::tei:surface/@xml:id}, + attribute next {$node/ancestor::tei:surface/@next}) + else if($node/ancestor::tei:surface/@prev) then + (attribute xml:id {$node/ancestor::tei:surface/@xml:id}, + attribute prev {$node/ancestor::tei:surface/@prev}) else () ) @@ -672,48 +677,14 @@ $log as xs:string) as node()* { attribute type {"short-paragraph-line"} } + else if($node/ancestor::tei:surface[@next or @prev]) then + fontaneSimple:make-img($node, $uri, $log,"double") + else if($node/ancestor::tei:zone[@type = "illustration"]) then - let $display := - if($node/ancestor::tei:zone[@type = "illustration"]/tei:milestone[@unit = "illustration"][. << $node]) then - "block" - else - "inline" - let $img-url := try {tbleapi:get-url($uri, $node/@xml:id, "png") } - catch * { fontaneSimple:add-log-entry($log, "No TBLE-file found for " || $node/@xml:id) } - let $img-url := - if($display = "inline") then - replace($img-url, ",1000", ",500") - else - $img-url - let $rotation := - (: no children and comment right after element:) - if($node/following-sibling::node()[1][self::comment()][matches(./string(), "rotate")] - and not($node/child::*)) then - substring-after($node/following::comment()[1], "rotate(") - => substring-before("deg") - (: comment as first descendant :) - else if($node/child::node()[1][self::comment()][matches(./string(), "rotate")]) then - substring-after($node/child::comment()[1], "rotate(") - => substring-before("deg") - else - () + fontaneSimple:make-img($node, $uri, $log, "") - return - element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{ - $node/@*, - attribute position {$display}, - attribute href {$img-url}, - if($rotation) then - attribute rotate {$rotation} - else - (), - fontaneSimple:transform($node/node(), $uri, $log) - } else - () -(: else:) -(: fontaneSimple:copy-element($node, $uri, $log):) case element(tei:note) return if($node/@type = "authorial" @@ -923,21 +894,6 @@ $uri as xs:string, $log as xs:string) as element(tei:seg) { }; -(:~ - : Creates a tei:pb. - : - : @author Michelle Weidling - : @param $node the current tei:surface node - : @return element(tei:pb) - :) -declare function fontaneSimple:make-pb($node as element(tei:surface)) -as element(tei:pb) { - element tei:pb { - $node/@n - } -}; - - (:~ : Creates a tei:pb with a type instead of a @n representing the pagination. : This function is mainly used to separate the inner and outer book covers from @@ -1324,3 +1280,68 @@ $message as xs:string) as empty-sequence() { let $entry := {$message} return update insert $entry into doc($log-file)/* }; + +declare function fontaneSimple:make-img($node as element(tei:figure), $uri as xs:string, +$log as xs:string, $flag as xs:string?) as element(tei:figure) { + let $display := + if($node/ancestor::tei:zone[@type = "illustration"]/tei:milestone[@unit = "illustration"][. << $node]) then + "block" + else + "inline" + let $img-url := try {tbleapi:get-url($uri, $node/@xml:id, "png") } + catch * { fontaneSimple:add-log-entry($log, "No TBLE-file found for " || $node/@xml:id) } + let $img-url := + if($display = "inline") then + replace($img-url, ",1000", ",500") + else + $img-url + let $rotation := + (: no children and comment right after element:) + if($node/following-sibling::node()[1][self::comment()][matches(./string(), "rotate")] + and not($node/child::*)) then + substring-after($node/following::comment()[1], "rotate(") + => substring-before("deg") + (: comment as first descendant :) + else if($node/child::node()[1][self::comment()][matches(./string(), "rotate")]) then + substring-after($node/child::comment()[1], "rotate(") + => substring-before("deg") + else + () + + return + element tei:figure { + $node/@*, + attribute href {$img-url}, + if($flag = "double") then + (attribute type {"double"}, + attribute id {util:hash(generate-id($node), "md5")}) + else + (), + if($rotation) then + attribute rotate {$rotation} + else + (), + fontaneSimple:transform($node/node(), $uri, $log) + } +}; + + +declare function fontaneSimple:make-double-img($node as element(tei:figure), +$uri as xs:string, $log as xs:string) as element(tei:figure)+ { + let $left-img-part := fontaneSimple:make-img($node, $uri, $log, "double") + let $right-img-part := fontaneSimple:make-right-img-part($node, $uri, $log) + + return + ($left-img-part, + $right-img-part) +}; + +declare function fontaneSimple:make-right-img-part($node as element(tei:figure), +$uri as xs:string, $log as xs:string) as element(tei:figure) { + let $next-id := $node/ancestor::tei:surface/@next + => replace("#", "") + let $corresp-node := $node/root()//tei:surface[@xml:id = $next-id]//tei:figure + + return + fontaneSimple:make-img($corresp-node, $uri, $log, "double") +}; diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index f4aa7ce5..4d60cf4a 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -38,6 +38,7 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { => tidySimple:split-headings() => tidySimple:remove-surplus-lines() => tidySimple:summarize() + => tidySimple:sort-double-imgs() (: => tidySimple:sort():) (: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):) let $header := @@ -233,6 +234,8 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string) tidySimple:summarize($node/node()) else if($flag = "ref") then tidySimple:get-references-in-abstract($node/node()) + else if($flag = "double-imgs") then + tidySimple:sort-double-imgs($node/node()) else tidySimple:tidy($node/node()) } @@ -703,3 +706,31 @@ declare function tidySimple:get-references-in-abstract($nodes as node()*) as nod default return tidySimple:copy-element($node, "ref") }; + + +declare function tidySimple:sort-double-imgs($nodes as node()*) as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + $node + + case comment() return + $node + + case element(tei:ab) return + if($node//tei:figure[@type = "double"]) then + if($node/@next) then + let $next-id := $node/@next + => replace("#", "") + let $corresp-node := $node/root()//*[@xml:id= $next-id] + return + ($node, $corresp-node) + else + () + else + tidySimple:copy-element($node, "double-imgs") + + default return + tidySimple:copy-element($node, "double-imgs") +}; -- GitLab From f3571001cde70dd4b6f3cab41303b2a3ebaf709d Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Wed, 7 Aug 2019 14:33:48 +0200 Subject: [PATCH 03/97] 3.7.13.2 Nicht ermittelte Skizzen --- modules/fontane/edited-text/tei2teisimple.xqm | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 6c944830..bc6af433 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -636,32 +636,21 @@ $log as xs:string) as node()* { ()) case element(tei:figure) return -(: if(count($node/child::*) = 2 :) -(: and $node/child::tei:figDesc:) -(: and $node/child::tei:ptr) then:) - (: genealogy lines probably shouldn't be displayed, but I still have to - check that. in case they should be serialized, I leave the code :) -(: if(matches($node/descendant::tei:ref, "Stammbaumverbindungslinie")) then:) -(: element tei:seg {:) -(: $node/@*,:) -(: fontaneSimple:transform($node/node(), $uri, $log):) -(: }:) -(: else if(matches($node/descendant::tei:ref, "Schlusslinie")):) - if(matches($node/descendant::tei:ref, "Schlusslinie")) - then - element tei:ab { - switch ($node/descendant::tei:ref) - case "horizontale einfache Schlusslinie" return - attribute type {"long-end-line"} - case "Schlusslinie; horizontale Halbschleife von links oben nach rechts" return - attribute type {"long-end-line"} - case "horizontale einfache Schlusslinie (gewellt)" return - attribute type {"long-end-line-wavy"} - case "Schlusslinien; horizontale Schleife von links oben nach rechts unten" return - attribute type {"bottom-brace-short"} - default return - attribute type {"end-line"} - } + if(matches($node/descendant::tei:ref, "Schlusslinie")) + then + element tei:ab { + switch ($node/descendant::tei:ref) + case "horizontale einfache Schlusslinie" return + attribute type {"long-end-line"} + case "Schlusslinie; horizontale Halbschleife von links oben nach rechts" return + attribute type {"long-end-line"} + case "horizontale einfache Schlusslinie (gewellt)" return + attribute type {"long-end-line-wavy"} + case "Schlusslinien; horizontale Schleife von links oben nach rechts unten" return + attribute type {"bottom-brace-short"} + default return + attribute type {"end-line"} + } else if(matches($node/descendant::tei:ref, "Absatzlinie") (: in case of double paragraph lines the single lines are @@ -677,6 +666,10 @@ $log as xs:string) as node()* { attribute type {"short-paragraph-line"} } + (: 3.7.13.2 Nicht ermittelte Skizzen :) + else if(not($node/@xml:id)) then + () + else if($node/ancestor::tei:surface[@next or @prev]) then fontaneSimple:make-img($node, $uri, $log,"double") -- GitLab From 26b60303e4a0a3771ed8c72e5338eb019ea70547 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Wed, 7 Aug 2019 15:15:42 +0200 Subject: [PATCH 04/97] 3.8.2.4.3.1 Addition --- modules/fontane/edited-text/simple2xhtml.xqm | 2 +- modules/fontane/edited-text/tei2teisimple.xqm | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index b573e5ae..0b5a6f44 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -300,7 +300,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } - else if($node/@type = "short-paragraph-line") then + else if($node/@type = ("short-paragraph-line", "sum", "double-sum")) then element xhtml:div { attribute class {$node/@type} } diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index bc6af433..d1ce249d 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -666,6 +666,16 @@ $log as xs:string) as node()* { attribute type {"short-paragraph-line"} } + else if(matches($node/descendant::tei:ref, "doppelter Summenstrich")) then + element tei:ab { + attribute type {"double-sum"} + } + + else if(matches($node/descendant::tei:ref, "Summenstrich")) then + element tei:ab { + attribute type {"sum"} + } + (: 3.7.13.2 Nicht ermittelte Skizzen :) else if(not($node/@xml:id)) then () -- GitLab From 372b72973a30585bdff593e405d44579bc445587 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 9 Aug 2019 13:07:07 +0200 Subject: [PATCH 05/97] Implement sums and differences --- modules/fontane/edited-text/simple2xhtml.xqm | 19 +++++++++++++++++-- modules/fontane/edited-text/tei2teisimple.xqm | 13 ++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 0b5a6f44..49902b98 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -155,8 +155,23 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () case element(tei:list) return + if($node[@subtype = "sum"]) then + let $no-of-cols := xs:integer(max($node//tei:seg[@type = "col"]/@n)) + let $no-of-rows := count($node//tei:seg[@type = "col" and @n = $no-of-cols]) + + return + element xhtml:table { + for $iii in 1 to $no-of-rows return + element xhtml:tr { + for $jjj in 1 to $no-of-cols return + element xhtml:td { + $node//tei:seg[@type = "col" and @n = $jjj][$iii] + } + } + } + (: this matches the FIRST element of the virtual aggregation :) - if($node/@next and not($node/@prev)) then + else if($node/@next and not($node/@prev)) then element xhtml:ul { attribute class {"nb-list"}, simple2xhtml:apply-next-element($node) @@ -300,7 +315,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } - else if($node/@type = ("short-paragraph-line", "sum", "double-sum")) then + else if($node/@type = ("short-paragraph-line", "sum", "double-sum", "difference")) then element xhtml:div { attribute class {$node/@type} } diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index d1ce249d..f82be22a 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -346,13 +346,7 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = "integration") then - element tei:seg { - $node/@*, - fontaneSimple:transform($node/node(), $uri, $log) - } - - else if($node/@type = "editorial-label") then + else if($node/@type = ("integration", "editorial-label", "col")) then element tei:seg { $node/@*, fontaneSimple:transform($node/node(), $uri, $log) @@ -676,6 +670,11 @@ $log as xs:string) as node()* { attribute type {"sum"} } + else if(matches($node/descendant::tei:ref, "Differenzstrich")) then + element tei:ab { + attribute type {"difference"} + } + (: 3.7.13.2 Nicht ermittelte Skizzen :) else if(not($node/@xml:id)) then () -- GitLab From 7d60317b25d83690345055d91deef796f14df31b Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 9 Aug 2019 14:11:37 +0200 Subject: [PATCH 06/97] Add docs --- modules/fontane/edited-text/abbrev-index.xqm | 2 +- modules/fontane/edited-text/etTransfo.xqm | 69 +++++++++++++++----- modules/fontane/edited-text/macro-sort.xqm | 5 ++ 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/modules/fontane/edited-text/abbrev-index.xqm b/modules/fontane/edited-text/abbrev-index.xqm index 9f8e079b..4b31ebfc 100644 --- a/modules/fontane/edited-text/abbrev-index.xqm +++ b/modules/fontane/edited-text/abbrev-index.xqm @@ -3,7 +3,7 @@ xquery version "3.1"; (:~ : This module is responsible for getting an XML version of the abbreviations : index which can be converted to TeX. This XML version is appended to - : fontane-full.xml during the creation of the intermediate format in etTransfo.xmq. + : fontane-full.xml during the creation of the intermediate format in etTransfo.xqm. : : @author Michelle Weidling : @version 0.1 diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index 7a4a8809..f4c53af1 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -37,7 +37,7 @@ declare variable $etTransfo:cases := "3qtqz.xml" (: case E :) ); -declare variable $etTransfo:dir := "/db/apps/SADE/modules/fontane/edited-text/"; +declare variable $etTransfo:coll := "/db/apps/SADE/modules/fontane/edited-text/"; (:~ @@ -150,7 +150,7 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string { declare function etTransfo:get-teis($showcase as xs:string) as element(tei:TEI)* { let $doc := doc("/db/sade-projects/textgrid/data/xml/data/" || $showcase) let $summary-file-name := $doc//tei:title[1] => replace(" ", "-") || ".xml" - let $log := doc($etTransfo:dir || "logs/" || $doc//tei:title[1] => replace(" ", "-") || "-log.xml") + let $log := doc($etTransfo:coll || "logs/" || $doc//tei:title[1] => replace(" ", "-") || "-log.xml") return try { doc($config:data-root || "/print/xml/" || $summary-file-name)//tei:TEI @@ -190,12 +190,20 @@ declare function etTransfo:create-htmls($showcase as xs:string) as xs:string* { :) declare function etTransfo:transform-tei($tei as element(tei:TEI), $log as xs:string) { (: macro-sort:main($tei, $tei/@id):) -(: => fsort:main():) +(: let $macro-sorted := + try { + macro-sort:main($tei, $tei/@id) + } catch * { + etTransfo:add-log-entry($log, "ETTRANSFO14: Error while macro sorting this notebook. Reason: " || + concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description)) +}:) let $sorted := try { fsort:main($tei, $log) + (: fsort:main($$macro-sorted, $log) :) } catch * { - etTransfo:add-log-entry($log, "ETTRANSFO09: Error while sorting this notebook. ") + etTransfo:add-log-entry($log, "ETTRANSFO09: Error while sorting this notebook. Reason: " || + concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description)) } let $prepare-comment := @@ -261,6 +269,7 @@ declare function etTransfo:create-print-tei() as xs:string { xmldb:store($config:data-root || "/print/xml/", "fontane-full.xml", $complete-print-file) }; + (:~ : An auxiliary function. Returns all final intermediate format TEI/XML files. : @@ -382,22 +391,43 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d }; +(:~ + : Creates a log file for a given notebook. + : + : @author Michelle Weidling + : @param $uri The notebook's URI, e.g. "12345.xml" + : @return The location of the stored log-file, e.g. "/db/apps/sade/modules/fontane/edited-text/logs/12345-log.xml" + :) declare function etTransfo:create-log($uri as xs:string) as xs:string { - let $assure-dir-available := etTransfo:assure-dir-available("logs") + let $assure-dir-available := etTransfo:assure-log-coll-available() let $log-name := $uri || "-log.xml" - return xmldb:store($etTransfo:dir || "logs", $log-name, ) + return xmldb:store($etTransfo:coll || "logs", $log-name, ) }; -declare function etTransfo:assure-dir-available($dir-name as xs:string) { - if(xmldb:collection-available($etTransfo:dir || "logs")) then - $etTransfo:dir || "logs" +(:~ + : Makes sure a requested collection is available. + : + : @author Michelle Weidling + : @return The location of the log collection, "/db/apps/sade/modules/fontane/edited-text/logs/" + :) +declare function etTransfo:assure-log-coll-available() { + if(xmldb:collection-available($etTransfo:coll || "logs")) then + $etTransfo:coll || "logs" else - xmldb:create-collection($etTransfo:dir, "logs") + xmldb:create-collection($etTransfo:coll, "logs") }; +(:~ + : Adds a log entry to a given log file. + : + : @author Michelle Weidling + : @param $log-file The path to the log file, e.g. "/db/apps/sade/modules/fontane/edited-text/logs/12345-log.xml" + : @param $message The message of the log entry + : @return The location of the log collection, "/db/apps/sade/modules/fontane/edited-text/logs/" + :) declare function etTransfo:add-log-entry($log-file as xs:string, $message as xs:string) as empty-sequence() { let $entry := {$message} @@ -406,24 +436,27 @@ $message as xs:string) as empty-sequence() { (:~ - : Only the logs which acutally contain info should be kept. - : + : Removes all log files that don't contain any information. + : @author Michelle Weidling :) -declare function etTransfo:tidy-logs() { - for $log in collection($etTransfo:dir || "logs/") return +declare function etTransfo:tidy-logs() as item()* { + for $log in collection($etTransfo:coll || "logs/") return if($log//LogEntry) then () else let $uri := substring-after(base-uri($log), "logs/") return - xmldb:remove($etTransfo:dir || "logs/", $uri) + xmldb:remove($etTransfo:coll || "logs/", $uri) }; - +(:~ + : Prints all errors found to stdout. + : @author Michelle Weidling + :) declare function etTransfo:report-errors() as item()* { - let $log-path := $etTransfo:dir || "logs/" + let $log-path := $etTransfo:coll || "logs/" return - if(xmldb:get-child-resources($log-path) = "") then + ifnormalize-space((xmldb:get-child-resources($log-path)) = "") then util:log-system-out("No errors found while creating the edited text! Yay!") else ( diff --git a/modules/fontane/edited-text/macro-sort.xqm b/modules/fontane/edited-text/macro-sort.xqm index a9436f77..4f4deaa8 100644 --- a/modules/fontane/edited-text/macro-sort.xqm +++ b/modules/fontane/edited-text/macro-sort.xqm @@ -1,5 +1,10 @@ xquery version "3.1"; +(:~ + : This module serves for getting the writing chronology on a macro level right. + : + :) + module namespace macro-sort="http://fontane-nb.dariah.eu/macro-sort"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; -- GitLab From bca4754dd3e645d917639c8194cfaa1ea589b541 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 12 Aug 2019 15:13:17 +0200 Subject: [PATCH 07/97] Create over all TOC as tei:div --- modules/fontane/edited-text/etTransfo.xqm | 39 ++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index f4c53af1..60fd581e 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -263,13 +263,18 @@ declare function etTransfo:create-print-tei() as xs:string { abbrev-index:main() } catch * { etTransfo:add-log-entry($log, "ETTRANSFO07: An error occured while creating the index of abbreviations.") + }, + + try { + etTransfo:create-overall-toc() + } catch * { + etTransfo:add-log-entry($log, "ETTRANSFO10: An error occured while creating the overall TOC..") } } return xmldb:store($config:data-root || "/print/xml/", "fontane-full.xml", $complete-print-file) }; - (:~ : An auxiliary function. Returns all final intermediate format TEI/XML files. : @@ -471,3 +476,35 @@ declare function etTransfo:report-errors() as item()* { util:log-system-out("Total: " || count(xmldb:get-child-resources($log-path)) || " notebook(s).") ) }; + + +declare function etTransfo:create-overall-toc() as element(tei:div) { + let $nbs := collection($config:data-root || "/data") + let $items := collection($config:data-root || "/data")//tei:TEI/tei:teiHeader//tei:msContents/tei:ab/tei:list[@type="editorial"]/tei:item + let $sortPattern := "^\W+" + + return element tei:div { + attribute type {"overall-toc"}, + let $segs := for $doc in $nbs return + let $nb-name := $doc//tei:fileDesc/tei:titleStmt/tei:title[1]/substring-after(., " ") + return + for $item in $doc//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:item return + let $refs := $item//tei:ref/@target/string() + return + element tei:seg { + attribute type {$nb-name}, + attribute source { + let $string := for $ref in $refs return + substring-after($ref, "@n='") + => substring-before("']") + return + string-join($string, " ") + + }, + functx:substring-before-last($item, ")") || ")" + } + return for $seg in $segs + order by replace($seg, $sortPattern, "") => substring(1, 1) => upper-case() + return $seg + } +}; -- GitLab From 202d0cacb22deb692d5532e1e2b7fcbab1d6998a Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 12 Aug 2019 15:15:07 +0200 Subject: [PATCH 08/97] Insert pagebreaks necessary for overall TOC --- modules/fontane/edited-text/sort.xqm | 17 +++++++++++++ modules/fontane/edited-text/tei2teisimple.xqm | 25 ++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 589633e8..c18d23d5 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -215,7 +215,9 @@ declare function fsort:keep-node($node as node(), $flag as xs:string, $log as xs element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, if($flag = "sort") then + (fsort:make-pb($node), fsort:sort($node/node(), $log) + ) else fsort:enhance-handshifts($node/node(), $log) } @@ -346,3 +348,18 @@ as node()* { default return fsort:keep-node($node, "handshift", $log) }; + + +declare function fsort:make-pb($node as node()) as attribute()? { + let $editorial-list-entries := $node/root()//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:ref + let $refs := for $entry in $editorial-list-entries return + $entry/@target/string() + => substring-after("@n='") + => substring-before("']") + let $refs := distinct-values($refs) + return + if($node/ancestor::tei:surface[1]/@n = $refs) then + attribute page {$node/ancestor::tei:surface[1]/@n} + else + () +}; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index f82be22a..820d0c02 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -395,20 +395,22 @@ $log as xs:string) as node()* { } else if($node/@type = "pocket") then + (fontaneSimple:make-pb($node), element tei:div{ $node/(@* except (@n, @ulx, @uly, @lry, @lrx)), fontaneSimple:transform($node/node(), $uri, $log) - } + }) else if(simpleHelpers:is-page($node) and $node/@type = "clipping") then (if($node/@subtype = "Kalenderblatt" and contains($node//tei:handShift/@new, "Friedrich_Fontane")) then + (fontaneSimple:make-pb($node), element tei:div { $node/@n, attribute type {$node/@subtype}, fontaneSimple:transform($node/node(), $uri, $log) - } + }) else if(not($node/@subtype = "Kalenderblatt")) then element tei:div { @@ -420,7 +422,8 @@ $log as xs:string) as node()* { ()) else if(simpleHelpers:is-page($node)) then - fontaneSimple:transform($node/node(), $uri, $log) + (fontaneSimple:make-pb($node), + fontaneSimple:transform($node/node(), $uri, $log)) else if($node/@type = "label" and (contains($node/@subtype, "Fontane") @@ -1347,3 +1350,19 @@ $uri as xs:string, $log as xs:string) as element(tei:figure) { return fontaneSimple:make-img($corresp-node, $uri, $log, "double") }; + +declare function fontaneSimple:make-pb($node as element(tei:surface)) as element(tei:pb)? { + let $editorial-list-entries := $node/root()//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:ref + let $refs := for $entry in $editorial-list-entries return + $entry/@target/string() + => substring-after("@n='") + => substring-before("']") + let $refs := distinct-values($refs) + return + if($node/@n = $refs) then + element tei:pb { + attribute n {$node/@n} + } + else + () +}; -- GitLab From dc72464e82e091327304251970a6e79e51e1395b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 26 Aug 2019 09:49:48 +0200 Subject: [PATCH 09/97] Implement 3.2.1.9 --- modules/fontane/edited-text/simple2xhtml.xqm | 16 ++++++--- modules/fontane/edited-text/tei2teisimple.xqm | 33 ++++++++++++++----- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 5d72f605..321c1645 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -146,11 +146,17 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:hi) return - (text{" "}, - element xhtml:span { - simple2xhtml:set-hs-info($node, "nb-underline"), - simple2xhtml:recursion($node/node()) - }) + if($node/ancestor::tei:seg[@type = "reduplication"]) then + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-reduplication"), + simple2xhtml:recursion($node/node()) + } + else + (text{" "}, + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-underline"), + simple2xhtml:recursion($node/node()) + }) case element(tei:lb) return if ($node/@type="edited_text") then diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index f0151476..76d2ea24 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -312,7 +312,7 @@ $log as xs:string) as node()* { then () - else if($node/parent::tei:add and $node/@copyOf) then + else if($node/ancestor::tei:add and $node/@copyOf) then fontaneSimple:mark-intervention($node, $uri, $log) else if($node/@type = "verse" and $node/@prev) then @@ -908,6 +908,21 @@ $uri as xs:string, $log as xs:string) as element(tei:seg) { }; +(:~ + : Creates a tei:pb. + : + : @author Michelle Weidling + : @param $node the current tei:surface node + : @return element(tei:pb) + :) +declare function fontaneSimple:make-pb($node as element(tei:surface)) +as element(tei:pb) { + element tei:pb { + $node/@n + } +}; + + (:~ : Creates a tei:pb with a type instead of a @n representing the pagination. : This function is mainly used to separate the inner and outer book covers from @@ -958,22 +973,24 @@ as element(tei:milestone) { declare function fontaneSimple:mark-intervention($node as element(*), $uri as xs:string, $log as xs:string) as element(tei:seg) { - element tei:seg { + let $type := if($node[self::tei:lb]) then - attribute type {"missing-hyphen"} + "missing-hyphen" else if($node[self::tei:surplus]) then - attribute type {"surplus"} + "surplus" else - attribute type {"reduplication"}, - - , + "reduplication" + return + element tei:seg { + attribute type {$type}, + , if($node[self::tei:lb]) then simpleHelpers:find-chars($node) else fontaneSimple:transform($node/node(), $uri, $log), - + } }; -- GitLab From d9965f6ff35d2cf5ab32cc079a5d09c4f22cb89b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 26 Aug 2019 10:45:47 +0200 Subject: [PATCH 10/97] Implement 3.2.2.3 --- modules/fontane/edited-text/tei2teisimple.xqm | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 76d2ea24..d71a76d7 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -32,14 +32,6 @@ import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at " : :) declare function fontaneSimple:main($doc as node()*, $uri as xs:string, $log as xs:string) as node()? { -(:declare function fontaneSimple:main($file as xs:string) as node()? {:) -(: let $doc :=:) -(: try {:) -(: (doc("/db/sade-projects/textgrid/data/xml/data/" || $file)):) -(: } catch * {:) -(: (console:log("It was not possible to open the requested file " || $file)):) -(: }:) - let $front-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "front_cover")] let $back-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "back_cover")] let $content := ($doc//tei:sourceDoc/tei:surface[not(contains(@n, "cover") @@ -723,7 +715,7 @@ $log as xs:string) as node()* { if($node[ancestor::tei:seg[@type = "editorial-label"]]) then $node/tei:abbr else - fontaneSimple:copy-element($node, $uri, $log) + fontaneSimple:mark-missing-syllable($node, $uri, $log) case element(tei:abbr) return fontaneSimple:copy-element($node, $uri, $log) @@ -994,6 +986,30 @@ as element(tei:seg) { } }; +declare function fontaneSimple:mark-missing-syllable($node as element(*), $uri as +xs:string, $log as xs:string) as element(tei:seg) { + let $sic := $node/tei:sic/string() + let $sic-length := string-length($sic) + let $corr := $node/tei:corr/string() + let $corr-length := string-length($corr) + + let $diff := $corr-length - $sic-length + let $missing := substring($corr, 1, $diff) + let $existent := $sic + + let $type := "missing-syllable" + + + return + element tei:seg { + attribute type {$type}, + , + $missing, + , + $existent + } +}; + declare function fontaneSimple:mark-missing-hyphen($node as element(tei:lb)) as element(tei:seg) { -- GitLab From a3e2af74f912e417a3ffb15f0e8eae5ce833b673 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 26 Aug 2019 11:05:39 +0200 Subject: [PATCH 11/97] Fix minor bugs in 3.2.2.3 --- modules/fontane/edited-text/simple2xhtml.xqm | 4 ++-- modules/fontane/edited-text/tei2teisimple.xqm | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 321c1645..4757b141 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -146,9 +146,9 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:hi) return - if($node/ancestor::tei:seg[@type = "reduplication"]) then + if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable")]) then element xhtml:span { - simple2xhtml:set-hs-info($node, "nb-reduplication"), + simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) } else diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index d71a76d7..36045aca 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -714,8 +714,10 @@ $log as xs:string) as node()* { case element(tei:choice) return if($node[ancestor::tei:seg[@type = "editorial-label"]]) then $node/tei:abbr - else + else if($node/tei:corr) then fontaneSimple:mark-missing-syllable($node, $uri, $log) + else + fontaneSimple:copy-element($node, $uri, $log) case element(tei:abbr) return fontaneSimple:copy-element($node, $uri, $log) -- GitLab From 072538109790350beeb723844b75b7acf3c40467 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 26 Aug 2019 12:57:57 +0200 Subject: [PATCH 12/97] Add first draft for 3.8.2.2.1.2 --- modules/fontane/edited-text/simple2xhtml.xqm | 11 ++++- modules/fontane/edited-text/tei2teisimple.xqm | 48 ++++++++----------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 4757b141..a169316a 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -304,7 +304,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { (: lines are handled together with tei:milestone[@unit = "start-lg"]. all other verses are ignored. :) case element(tei:l) return - () + element xhtml:div { + attribute class {"nb-verse"}, + simple2xhtml:recursion($node/node()) + } case element(tei:ab) return if($node/@type = "sketch" @@ -397,6 +400,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { if($node/@type = ("caption", "editorial-label", "multiphrase")) then () + else if($node/@type = "verse") then + element xhtml:div { + attribute class {"nb-verses"}, + simple2xhtml:recursion($node/node()) + } + else if($node[@rendition = ("vertical-align:super", "vertical-align:sub") and (following-sibling::*[1][self::tei:g[@ref ="#hb"]] diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 36045aca..4c27c032 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -200,35 +200,30 @@ $log as xs:string) as node()* { (simpleHelpers:start-line($node), simpleHelpers:trim-first-char($node)) - else if($node/@type = "verse") then + else if($node/@type = "verse" + or $node/ancestor::tei:zone[@type = "verse"]) then if($node/@prev) then () else if(not($node/@next)) then - (if(not($node/preceding-sibling::tei:line[@type = "verse"])) then - fontaneSimple:mark-linegroup-beginning() - else - (), element tei:l { + if($node/@rend) then + attribute subtype {$node/@rend} + else + (), fontaneSimple:transform($node/node(), $uri, $log) - }, - if(not($node/following-sibling::tei:line[@type = "verse"])) then - fontaneSimple:mark-linegroup-end() - else - ()) + } (: 3.8.2.2.1.3 Vers mit anderer Beschriftung in einer Zeile :) else let $corresp := $node/following::*[@type = "verse" and replace($node/@next, "#", "") = @xml:id] return - (fontaneSimple:mark-linegroup-beginning(), element tei:l { fontaneSimple:transform($node/node(), $uri, $log), simpleHelpers:start-line($node), fontaneSimple:transform($corresp/node(), $uri, $log) - }, - fontaneSimple:mark-linegroup-end()) + } else if($node/parent::tei:zone[@type = "verse"]/child::*[1] = $node) then fontaneSimple:transform($node/node(), $uri, $log) @@ -547,19 +542,16 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = "verse") then - (fontaneSimple:mark-linegroup-beginning(), - element tei:l { - fontaneSimple:transform($node/node(), $uri, $log) - }, - fontaneSimple:mark-linegroup-end()) - else if($node/@type = "said" and $node/@prev) then () - else if($node/@type = "said") then + else if($node/@type = ("verse", "said")) then element tei:seg { - $node/@type, + attribute type {$node/@type}, + if($node/@rend) then + attribute subtype {$node/@rend} + else + (), fontaneSimple:transform($node/node(), $uri, $log) } @@ -600,17 +592,19 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) else if($node/@xml:id) then - ( -(: if($node/@xml:id = "C06_14r_9") then:) -(: util:log-system-out($node):) -(: else (),:) element tei:seg { $node/@xml:id, $node/@prev, $node/@next, $node/@corresp, fontaneSimple:transform($node/node(), $uri, $log) - }) + } + + else if($node/@rend) then + element tei:seg { + attribute subtype {$node/@rend}, + fontaneSimple:transform($node/node(), $uri, $log) + } else fontaneSimple:transform($node/node(), $uri, $log) -- GitLab From c7347d1523c7f21cdcde6336e93294e632b96b1e Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 27 Aug 2019 10:21:27 +0200 Subject: [PATCH 13/97] Further work on 3.8.2.2.1.2 --- modules/fontane/edited-text/simple2xhtml.xqm | 26 ++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index a169316a..ae6b5ce0 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -301,13 +301,18 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () - (: lines are handled together with tei:milestone[@unit = "start-lg"]. all - other verses are ignored. :) case element(tei:l) return - element xhtml:div { + (element xhtml:div { attribute class {"nb-verse"}, simple2xhtml:recursion($node/node()) - } + }, + if($node/following-sibling::*[1][not(self::tei:seg[@type = "verse"] or self::tei:l)]) then + element xhtml:span { + attribute class {"nb-verses-end"} + } + else + () + ) case element(tei:ab) return if($node/@type = "sketch" @@ -401,10 +406,17 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () else if($node/@type = "verse") then - element xhtml:div { - attribute class {"nb-verses"}, + (element xhtml:div { + attribute class {"nb-verse"}, simple2xhtml:recursion($node/node()) - } + }, + if($node/following-sibling::*[1][not(self::tei:seg[@type = "verse"] or self::tei:l)]) then + element xhtml:span { + attribute class {"nb-verses-end"} + } + else + () + ) else if($node[@rendition = ("vertical-align:super", "vertical-align:sub") and -- GitLab From c94dc033a60b6db828f58052780cdc83085b46ad Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 27 Aug 2019 10:21:57 +0200 Subject: [PATCH 14/97] Remove surplus code --- modules/fontane/edited-text/sort.xqm | 32 ---------------------------- 1 file changed, 32 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 32ec6c9d..a288fd48 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -63,38 +63,6 @@ declare function fsort:sort($nodes as node()*, $log as xs:string) { case element(tei:rs) return fsort:default-return($node, $log) -(: case element(tei:hi) return:) -(: if($node/@next and not($node/ancestor::tei:rs)) then:) -(: let $corresp-node := fsort:find-corresp-node($node, "next"):) -(: return:) -(: (: it's not sufficient to copy only the corresp node since:) -(: this would mean we'd loose the information about the tei:rs :):) -(: if($corresp-node[self::tei:hi and parent::tei:rs]) then:) -(: (fsort:keep-node($node),:) -(: element {QName("http://www.tei-c.org/ns/1.0", "rs")} {:) -(: $corresp-node/parent::*/@*,:) -(: $corresp-node:) -(: }):) -(: else:) -(: fsort:default-return($node):) -(: else:) -(: fsort:default-return($node):) -(::) -(::) -(: case element(tei:rs) return:) -(: (: in this case the tei:rs is empty after fsort:apply-all-nexts. we:) -(: don't need these. :):) -(: if($node[child::*[@prev]] and count($node/child::*) = 1) then:) -(: ():) -(: else:) -(: fsort:default-return($node):) -(: :) -(: case element(tei:date) return:) -(: fsort:keep-node($node):) -(::) -(: case element(tei:ref) return:) -(: fsort:keep-node($node):) - default return fsort:keep-node($node, "sort", $log) }; -- GitLab From 5e8a8dcde4106aadf91867ef284891dd6e06bbc9 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 27 Aug 2019 10:22:46 +0200 Subject: [PATCH 15/97] Implement 3.8.2.3.6 --- modules/fontane/edited-text/tei2teisimple.xqm | 17 ++++++--- modules/fontane/edited-text/tidysimple.xqm | 36 +++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 4c27c032..4011bd3b 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -78,7 +78,8 @@ $log as xs:string) as node()* { or $node/ancestor::tei:desc[@type = "edited_text"] or $node/ancestor::tei:note[@type = "editorial"] or $node/ancestor::tei:seg[@type = "editorial-label"] - or $node/ancestor::tei:ref[not(matches(@target, "getty") or matches(@target, "xpath"))]) then + or $node/ancestor::tei:ref[not(matches(@target, "getty") or matches(@target, "xpath"))] + or $node/ancestor::tei:seg[@type = "heading"]) then if($node/parent::tei:rs and starts-with($node, " ") and not($node/preceding-sibling::*[1][self::tei:handShift or self::tei:hi]) and simpleHelpers:is-trimming-necessary($node)) then @@ -841,7 +842,7 @@ $log as xs:string) as element(tei:head) { ), $node/@subtype, - + $node/@xml:id, (if($node//tei:hi) then attribute underlined {"true"} else @@ -852,10 +853,18 @@ $log as xs:string) as element(tei:head) { else ()), - (if($node/@rend) then + if($node/@rend) then $node/@rend else - ()), + (), + if($node/@next) then + $node/@next + else + (), + if($node/@prev) then + $node/@prev + else + (), fontaneSimple:transform($node/node(), $uri, $log) } }; diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index a0bed2cb..f9077f5c 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -36,6 +36,7 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { => tidySimple:sort-out-invalid-hands() => tidySimple:split-headings() => tidySimple:summarize() + => tidySimple:summarize-headings() => tidySimple:sort-double-imgs() (: => tidySimple:sort():) (: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):) @@ -272,8 +273,8 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string) tidySimple:get-Fontanes-sources($node/node()) else if($flag = "summarize") then tidySimple:summarize($node/node()) - else if($flag = "summarize-hi") then - tidySimple:summarize-hi($node/node()) + else if($flag = "summarize-headings") then + tidySimple:summarize-headings($node/node()) else if($flag = "ref") then tidySimple:get-references-in-abstract($node/node()) else if($flag = "double-imgs") then @@ -632,3 +633,34 @@ declare function tidySimple:sort-double-imgs($nodes as node()*) as node()* { default return tidySimple:copy-element($node, "double-imgs") }; + + +declare function tidySimple:summarize-headings($nodes as node()*) as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + $node + + case comment() return + $node + + case element(tei:head) return + if($node/@next) then + let $next-id := tidySimple:get-id($node/@next) + let $corresp-node := tidySimple:find-corresp-node($node, "next") + + return + element tei:head { + $node/@*, + $node/node(), + $corresp-node/node() + } + else if($node/@prev) then + () + else + tidySimple:copy-element($node, "summarize-headings") + + default return + tidySimple:copy-element($node, "summarize-headings") +}; -- GitLab From 240aec7eda1ac64bdf13bdf4f987c62b4b0f1840 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 27 Aug 2019 10:41:14 +0200 Subject: [PATCH 16/97] Migrate presort.xqm to sort.xqm --- modules/fontane/edited-text/presort.xqm | 131 ---------------- modules/fontane/edited-text/sort.xqm | 143 +++++++++++++++--- .../edited-text/tests/presort-test-runner.xq | 12 -- .../fontane/edited-text/tests/presort-test.xq | 76 ---------- 4 files changed, 124 insertions(+), 238 deletions(-) delete mode 100644 modules/fontane/edited-text/presort.xqm delete mode 100644 modules/fontane/edited-text/tests/presort-test-runner.xq delete mode 100644 modules/fontane/edited-text/tests/presort-test.xq diff --git a/modules/fontane/edited-text/presort.xqm b/modules/fontane/edited-text/presort.xqm deleted file mode 100644 index 06e0b832..00000000 --- a/modules/fontane/edited-text/presort.xqm +++ /dev/null @@ -1,131 +0,0 @@ -xquery version "3.1"; - -module namespace presort="http://fontane-nb.dariah.eu/presort"; - -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace test="http://exist-db.org/xquery/xqsuite"; - -import module namespace functx="http://www.functx.com"; -import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm"; - - -(:~ - : Marks all nodes that are part of an interlinear addition. - : - : @author Michelle Weidling - : @param $node The current node - : @return The processed node - :) -declare function presort:prepare($nodes as node()*) as node()* { - for $node in $nodes - return - typeswitch ($node) - case text() return - $node - - case comment() return - if(matches($node/string(), "rotate")) then - $node - else - () - - default return - if($node/preceding-sibling::*[self::tei:addSpan][1][@place = 'interlinear'][@prev or @next] - and not($node[self::tei:anchor])) then - presort:mark-interlinear-node-to-be-moved($node) - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - presort:prepare($node/node()) - } - -}; - - -(:~ - : Interlinear additions can be part of a virtual aggregation. Since their - : start is marked by tei:addSpan and their end by tei:anchor, all nodes inbetween - : have to be moved when the right chronology is established, too. To make this - : easier, the respective nodes are marked with an attribute. - : - : All other nodes are simply copied. - : - : @author Michelle Weidling - : @param $node The current node - : @return The processed node - :) -declare function presort:mark-interlinear-node-to-be-moved($node as element()) -as element() { - let $addSpan := $node/preceding-sibling::*[self::tei:addSpan][1][@place = 'interlinear'][@prev or @next] - let $spanTo := substring-after($addSpan/@spanTo, "#") - let $anchor := $addSpan/following::tei:anchor[@xml:id = $spanTo] - let $nodes-inbetween := $addSpan/following-sibling::*[. << $anchor] - - return - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - if(functx:is-node-in-sequence-deep-equal($node, $nodes-inbetween)) then - attribute type {"interlinear"} - else - (), - $node/node() - } -}; - - -(:~ - : Creates a new encoding structure for tei:metamark[@function = "integrate"] - : that makes further processing of them easier. All nodes relevant for the - : integration brackets are summarized in a tei:seg[@type = 'integration']. - : - : @author Michelle Weidling - : @param $node The current node - : @return The processed node - :) -declare function presort:sort-integrations($nodes as node()*) as node()* { - for $node in $nodes return - if($node/@xml:id) then - let $id := $node/@xml:id - let $metamarks := $node/ancestor::*[last()]//tei:metamark[@function = "integrate"] - let $linking-node-corresp := $metamarks[substring-after(@corresp, "#") = $id] - let $linking-node-target := $metamarks[substring-after(@target, "#") = $id] - - return - if($linking-node-corresp and not($linking-node-target)) then - let $integration-target-id := replace($linking-node-corresp/@target, "#", "") - let $integration-comment := $linking-node-corresp/ancestor::*[last()]//*[@xml:id = $integration-target-id] - return - element tei:seg { - attribute type {"integration"}, - $integration-comment, - $linking-node-corresp, - presort:keep-node-integrations($node) - } - else if($linking-node-target) then - () - else - presort:keep-node-integrations($node) - - else if($node[self::tei:metamark[@function = "integrate"]]) then - () - else if($node[self::text() or self::comment()]) then - $node - else - presort:keep-node-integrations($node) -}; - - -(:~ - : An auxiliary function that copies a given node while sorting the integrations. - : - : @author Michelle Weidling - : @param $node The current node - : @return A copy of the given node - :) -declare function presort:keep-node-integrations($node as node()) as node()* { - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, -(: $node/(@* except (@prev, @next)), (: attrs only visible for debugging :):) - presort:sort-integrations($node/node()) - } -}; diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index a288fd48..2ee57af5 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -14,22 +14,22 @@ module namespace fsort="http://fontane-nb.dariah.eu/sort"; declare namespace tei="http://www.tei-c.org/ns/1.0"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; -import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm"; +import module namespace functx="http://www.functx.com"; (:~ : The main function. Sorts each notebook and saves a sorted version at - : /db/sade-projects/textgrid/data/xml/print/xml/notebook_uri-presort.xml. + : /db/sade-projects/textgrid/data/xml/print/xml/notebook_uri-sorted.xml. : : @author Michelle Weidling :) declare function fsort:main($tei as node()*, $log as xs:string) as element(tei:TEI) { - let $prepared := presort:prepare($tei) + let $prepared := fsort:prepare($tei) let $prepared := fsort:enhance-handshifts($prepared, $log) let $tei := fsort:sort($prepared, $log) - let $fully-sorted := presort:sort-integrations($tei) + let $fully-sorted := fsort:sort-integrations($tei) let $id := $tei/@id - let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-presort.xml", $fully-sorted) + let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $fully-sorted) return $fully-sorted }; @@ -99,7 +99,7 @@ declare function fsort:default-return($node as node(), $log as xs:string) as nod fsort:keep-node($node, "sort", $log) (: nodes with this attribute are part of an interlinear addition; they have - been marked by presort:prepare. since interlinear additions are handled as a + been marked by fsort:prepare. since interlinear additions are handled as a whole and put into the right place, their elements can be safely dumped here :) else if($node[@type = "interlinear"]) then () @@ -197,9 +197,7 @@ declare function fsort:keep-node($node as node(), $flag as xs:string, $log as xs element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, if($flag = "sort") then - (fsort:make-pb($node), fsort:sort($node/node(), $log) - ) else fsort:enhance-handshifts($node/node(), $log) } @@ -332,16 +330,123 @@ as node()* { }; -declare function fsort:make-pb($node as node()) as attribute()? { - let $editorial-list-entries := $node/root()//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:ref - let $refs := for $entry in $editorial-list-entries return - $entry/@target/string() - => substring-after("@n='") - => substring-before("']") - let $refs := distinct-values($refs) +(:~ + : Marks all nodes that are part of an interlinear addition. + : + : @author Michelle Weidling + : @param $node The current node + : @return The processed node + :) +declare function fsort:prepare($nodes as node()*) as node()* { + for $node in $nodes + return + typeswitch ($node) + case text() return + $node + + case comment() return + if(matches($node/string(), "rotate")) then + $node + else + () + + default return + if($node/preceding-sibling::*[self::tei:addSpan][1][@place = 'interlinear'][@prev or @next] + and not($node[self::tei:anchor])) then + fsort:mark-interlinear-node-to-be-moved($node) + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + fsort:prepare($node/node()) + } + +}; + + +(:~ + : Interlinear additions can be part of a virtual aggregation. Since their + : start is marked by tei:addSpan and their end by tei:anchor, all nodes inbetween + : have to be moved when the right chronology is established, too. To make this + : easier, the respective nodes are marked with an attribute. + : + : All other nodes are simply copied. + : + : @author Michelle Weidling + : @param $node The current node + : @return The processed node + :) +declare function fsort:mark-interlinear-node-to-be-moved($node as element()) +as element() { + let $addSpan := $node/preceding-sibling::*[self::tei:addSpan][1][@place = 'interlinear'][@prev or @next] + let $spanTo := substring-after($addSpan/@spanTo, "#") + let $anchor := $addSpan/following::tei:anchor[@xml:id = $spanTo] + let $nodes-inbetween := $addSpan/following-sibling::*[. << $anchor] + return - if($node/ancestor::tei:surface[1]/@n = $refs) then - attribute page {$node/ancestor::tei:surface[1]/@n} - else - () + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + if(functx:is-node-in-sequence-deep-equal($node, $nodes-inbetween)) then + attribute type {"interlinear"} + else + (), + $node/node() + } +}; + + +(:~ + : Creates a new encoding structure for tei:metamark[@function = "integrate"] + : that makes further processing of them easier. All nodes relevant for the + : integration brackets are summarized in a tei:seg[@type = 'integration']. + : + : @author Michelle Weidling + : @param $node The current node + : @return The processed node + :) +declare function fsort:sort-integrations($nodes as node()*) as node()* { + for $node in $nodes return + if($node/@xml:id) then + let $id := $node/@xml:id + let $metamarks := $node/root()//tei:metamark[@function = "integrate"] + let $linking-node-corresp := $metamarks[substring-after(@corresp, "#") = $id] + let $linking-node-target := $metamarks[substring-after(@target, "#") = $id] + + return + if($linking-node-corresp and not($linking-node-target)) then + let $integration-target-id := replace($linking-node-corresp/@target, "#", "") + let $integration-comment := $linking-node-corresp/ancestor::*[last()]//*[@xml:id = $integration-target-id] + return + element tei:seg { + attribute type {"integration"}, + $integration-comment, + $linking-node-corresp, + fsort:keep-node-integrations($node) + } + else if($linking-node-target) then + () + else + fsort:keep-node-integrations($node) + + else if($node[self::tei:metamark[@function = "integrate"]]) then + () + else if($node[self::text() or self::comment()]) then + $node + else + fsort:keep-node-integrations($node) +}; + + +(:~ + : An auxiliary function that copies a given node while sorting the integrations. + : + : @author Michelle Weidling + : @param $node The current node + : @return A copy of the given node + :) +declare function fsort:keep-node-integrations($node as node()) as node()* { + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, +(: $node/(@* except (@prev, @next)), (: attrs only visible for debugging :):) + fsort:sort-integrations($node/node()) + } }; diff --git a/modules/fontane/edited-text/tests/presort-test-runner.xq b/modules/fontane/edited-text/tests/presort-test-runner.xq deleted file mode 100644 index 6de684f0..00000000 --- a/modules/fontane/edited-text/tests/presort-test-runner.xq +++ /dev/null @@ -1,12 +0,0 @@ -xquery version "3.1"; - -(: This main module starts the tests stored in teisimple-test.xql. :) - -import module namespace presort-test = "http://fontane-nb.dariah.eu/presort-test" at "presort-test.xq"; -import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql"; - -declare namespace tei="http://www.tei-c.org/ns/1.0"; - -test:suite( - util:list-functions("http://fontane-nb.dariah.eu/presort-test") -) diff --git a/modules/fontane/edited-text/tests/presort-test.xq b/modules/fontane/edited-text/tests/presort-test.xq deleted file mode 100644 index 3210580c..00000000 --- a/modules/fontane/edited-text/tests/presort-test.xq +++ /dev/null @@ -1,76 +0,0 @@ -xquery version "3.1"; - -(: This library module contains XQSuite tests for the presorting module stored - : in ../presort.xqm :) - -module namespace presort-test = "http://fontane-nb.dariah.eu/presort-test"; - -import module namespace presort="http://fontane-nb.dariah.eu/presort" at "../presort.xqm"; - -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace test="http://exist-db.org/xquery/xqsuite"; - - -(: Text :) -declare - %test:name("Text nodes") - %test:args("Just some text") - %test:assertEquals("Just some text") - - %test:args("Text with Ümläöuts") - %test:assertEquals("Text with Ümläöuts") - - %test:args("Hiſtoriſches ✓") - %test:assertEquals("Hiſtoriſches ✓") - function presort-test:text($node as text()) { - presort:sort($node) -}; - -(: Default nodes :) -declare - %test:name("Default nodes") - %test:args("") - %test:assertEquals("") - - %test:args("STAATSBIBLIOTHEK •BERLIN•") - %test:assertEquals("STAATSBIBLIOTHEK •BERLIN•") - function presort-test:default-nodes($node as element(*)) { - presort:sort($node) -}; - - -(: @next nodes :) -declare - %test:name("Establishing right order with @next nodes") - (: case 1: two elements referencing each other also stand right next to each - other, i.e. there's no text inbetween. then nothing should happen :) - %test:args("in das Auguſtinerkloſterzu Erfurt") - %test:assertEquals("in das Auguſtinerkloſterzu Erfurt") - - (: case 2: two elements referencing each other are seperated by an arbitrary - amout of text. then they should be sorted into the right order :) - %test:args("2. Luther, Eisleben1483Some TextEin Stück ſeines Mantels und ſei") - %test:assertEquals("2. Luther, Eisleben1483Ein Stück ſeines Mantels und ſeiSome Text") - - function presort-test:next-nodes($node as element(*)) { - presort:sort($node) -}; - - -(: @prev nodes :) -declare - %test:name("Omit @prev nodes") - %test:args("") - %test:assertEquals("") - - %test:args("STAATSBIBLIOTHEK •BERLIN•") - %test:assertEquals("STAATSBIBLIOTHEK •BERLIN•") - - %test:args("STAATSBIBLIOTHEK •BERLIN•") - %test:assertEquals("STAATSBIBLIOTHEK •BERLIN•") - - %test:args("STAATSBIBLIOTHEK •BERLIN•") - %test:assertEquals("STAATSBIBLIOTHEK •BERLIN•") - function presort-test:omit-prev-nodes($node as element(*)) { - presort:sort($node) -}; -- GitLab From 1ce14cca3e46adcd5cbd77759f2b7ae14f3fa473 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 27 Aug 2019 11:52:59 +0200 Subject: [PATCH 17/97] Implement 3.8.2.5.1.2 --- modules/fontane/edited-text/simple2xhtml.xqm | 5 ++ modules/fontane/edited-text/sort.xqm | 56 ++++++++----------- modules/fontane/edited-text/tei2teisimple.xqm | 4 +- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index ae6b5ce0..42b6fcfe 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -465,6 +465,11 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { attribute class {"nb-footnote"}, simple2xhtml:recursion($node/node()) } + else if($node/@subtype = "revision") then + element xhtml:div { + attribute class {"nb-revision"}, + simple2xhtml:recursion($node/node()) + } else () diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 2ee57af5..1f56759d 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -25,12 +25,12 @@ import module namespace functx="http://www.functx.com"; declare function fsort:main($tei as node()*, $log as xs:string) as element(tei:TEI) { let $prepared := fsort:prepare($tei) let $prepared := fsort:enhance-handshifts($prepared, $log) - let $tei := fsort:sort($prepared, $log) - let $fully-sorted := fsort:sort-integrations($tei) + let $fully-sorted := fsort:sort($prepared, $log) + let $integrations := fsort:sort-integrations($fully-sorted, $log) let $id := $tei/@id - let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $fully-sorted) - return $fully-sorted + let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $integrations) + return $integrations }; @@ -64,7 +64,7 @@ declare function fsort:sort($nodes as node()*, $log as xs:string) { fsort:default-return($node, $log) default return - fsort:keep-node($node, "sort", $log) + fsort:copy-node($node, "sort", $log) }; (:~ @@ -84,7 +84,7 @@ declare function fsort:default-return($node as node(), $log as xs:string) as nod or similar), their @prev/@next doesn't indicate the chronology but only the continuation of the highlighting. they should thus be omitted.:) if(matches($node/@style, "underline")) then - fsort:keep-node($node, "sort", $log) + fsort:copy-node($node, "sort", $log) else if($node[@next and not(@prev)]) then fsort:apply-all-nexts($node, $log) @@ -96,7 +96,7 @@ declare function fsort:default-return($node as node(), $log as xs:string) as nod (: we distinguish this case and the one below to improve performance :) else if($node[descendant::*[@next or @prev]]) then - fsort:keep-node($node, "sort", $log) + fsort:copy-node($node, "sort", $log) (: nodes with this attribute are part of an interlinear addition; they have been marked by fsort:prepare. since interlinear additions are handled as a @@ -129,7 +129,7 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no return for $node-inbetween in $nodes-inbetween return - fsort:keep-node($node-inbetween, "sort", $log) + fsort:copy-node($node-inbetween, "sort", $log) else (: first element of a virtual aggregation: entry point :) @@ -137,7 +137,7 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no let $next-node := fsort:find-corresp-node($node, "next") return if(count($next-node) = 1) then - (fsort:keep-node($node, "sort", $log), + (fsort:copy-node($node, "sort", $log), (: check if the parts are in different lines :) if($node/ancestor::tei:line = $next-node/ancestor::tei:line) then () @@ -154,7 +154,7 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no (: last of a virtual aggregation: exit point :) else if(not($node/@next)) then ($node/preceding::tei:handShift[1], - fsort:keep-node($node, "sort", $log)) + fsort:copy-node($node, "sort", $log)) (: element in the middle of a virtual aggregation:) else @@ -163,7 +163,7 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no return if(count($next-node) = 1) then ($prev-handshift, - fsort:keep-node($node, "sort", $log), + fsort:copy-node($node, "sort", $log), (: check if the parts are in different lines :) if($node/ancestor::tei:line = $next-node/ancestor::tei:line) then () @@ -193,13 +193,17 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no : @param $node the current node : @return a copy of the current node with sorted descendants :) -declare function fsort:keep-node($node as node(), $flag as xs:string, $log as xs:string) as node() { +declare function fsort:copy-node($node as node(), $flag as xs:string, $log as xs:string) as node() { element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, if($flag = "sort") then fsort:sort($node/node(), $log) - else + else if($flag = "handshift") then fsort:enhance-handshifts($node/node(), $log) + else if($flag = "sort-integrations") then + fsort:sort-integrations($node/node(), $log) + else + error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) } }; @@ -326,7 +330,7 @@ as node()* { } default return - fsort:keep-node($node, "handshift", $log) + fsort:copy-node($node, "handshift", $log) }; @@ -403,7 +407,7 @@ as element() { : @param $node The current node : @return The processed node :) -declare function fsort:sort-integrations($nodes as node()*) as node()* { +declare function fsort:sort-integrations($nodes as node()*, $log as xs:string) as node()* { for $node in $nodes return if($node/@xml:id) then let $id := $node/@xml:id @@ -420,33 +424,17 @@ declare function fsort:sort-integrations($nodes as node()*) as node()* { attribute type {"integration"}, $integration-comment, $linking-node-corresp, - fsort:keep-node-integrations($node) + fsort:copy-node($node, "sort-integrations", $log) } else if($linking-node-target) then () else - fsort:keep-node-integrations($node) + fsort:copy-node($node, "sort-integrations", $log) else if($node[self::tei:metamark[@function = "integrate"]]) then () else if($node[self::text() or self::comment()]) then $node else - fsort:keep-node-integrations($node) -}; - - -(:~ - : An auxiliary function that copies a given node while sorting the integrations. - : - : @author Michelle Weidling - : @param $node The current node - : @return A copy of the given node - :) -declare function fsort:keep-node-integrations($node as node()) as node()* { - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, -(: $node/(@* except (@prev, @next)), (: attrs only visible for debugging :):) - fsort:sort-integrations($node/node()) - } + fsort:copy-node($node, "sort-integrations", $log) }; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 4011bd3b..7191198b 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -562,7 +562,7 @@ $log as xs:string) as node()* { else if($node/@type = "toc") then element tei:div { - $node/(@type, @subtype), + $node/(@type, @subtype, @xml:id), fontaneSimple:transform($node/node(), $uri, $log) } @@ -683,7 +683,7 @@ $log as xs:string) as node()* { case element(tei:note) return if($node/@type = "authorial" - and not($node/@subtype = "footnote")) then + and not($node/@subtype = ("footnote", "revision"))) then () else fontaneSimple:copy-element($node, $uri, $log) -- GitLab From e8a44efb8fc04ffb941885e7d80fd56d7a3d14d7 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 28 Aug 2019 08:40:14 +0200 Subject: [PATCH 18/97] Implement 3.2.2.1 --- modules/fontane/edited-text/simple2xhtml.xqm | 8 +++++++- modules/fontane/edited-text/tidysimple.xqm | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 42b6fcfe..1be13877 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -146,7 +146,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:hi) return - if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable")]) then + if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable", "missing-hyphen")]) then element xhtml:span { simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) @@ -428,6 +428,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/@type = "integration") then simple2xhtml:make-integration($node) + else if($node/@type = "missing-hyphen") then + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-missing-hyphen"), + simple2xhtml:recursion($node/node()) + } + else element xhtml:span { simple2xhtml:set-hs-info($node, "nb-seg"), diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index f9077f5c..312f9d4d 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -149,6 +149,11 @@ as node()* { tidySimple:sort-out-surplus-elements($node/node()) } + else if($node/@unit = "line" + and ($node/ancestor::tei:seg[@type = "missing-hyphen"] + or $node/preceding-sibling::*[1][self::tei:seg[@type = "missing-hyphen"]])) then + () + else element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, -- GitLab From 10e94c68e8f552b510c4ff9f4083580c09902130 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 28 Aug 2019 14:06:12 +0200 Subject: [PATCH 19/97] Implement 3.8.2.4.3 --- modules/fontane/edited-text/simple2xhtml.xqm | 55 +++++++++---------- modules/fontane/edited-text/tei2teisimple.xqm | 13 +++++ modules/fontane/edited-text/tidysimple.xqm | 6 +- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 1be13877..fd1ba874 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -165,35 +165,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () case element(tei:list) return - if($node[@subtype = "sum"]) then - let $no-of-cols := xs:integer(max($node//tei:seg[@type = "col"]/@n)) - let $no-of-rows := count($node//tei:seg[@type = "col" and @n = $no-of-cols]) - - return - element xhtml:table { - for $iii in 1 to $no-of-rows return - element xhtml:tr { - for $jjj in 1 to $no-of-cols return - element xhtml:td { - $node//tei:seg[@type = "col" and @n = $jjj][$iii] - } - } - } - - (: this matches the FIRST element of the virtual aggregation :) - else if($node/@next and not($node/@prev)) then - element xhtml:ul { - attribute class {"nb-list"}, - simple2xhtml:apply-next-element($node) - } - (: this matches all OTHER elements of the virtual aggregation :) - else if($node/@prev or $node/@next) then - () - else - element xhtml:ul { - attribute class {"nb-list"}, - simple2xhtml:recursion($node/node()) - } + element xhtml:ul { + attribute class {"nb-list"}, + simple2xhtml:recursion($node/node()) + } case element(tei:item) return element xhtml:li { @@ -262,7 +237,11 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:milestone) return - if($node/@unit = "line") then + if($node/@unit = "line" + and $node/ancestor::tei:list and not($node/ancestor::tei:item)) then + element xhtml:br {} + + else if($node/@unit = "line") then let $next-char := substring($node/following::text()[1], 1, 1) return if(matches($next-char, "[\.\)\?,;!]") @@ -518,6 +497,22 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else () + case element(tei:table) return + (element xhtml:table { + attribute class {"nb-computation-table"}, + simple2xhtml:recursion($node/tei:row) + }, + simple2xhtml:recursion($node/node()[not(ancestor-or-self::tei:row)])) + + case element(tei:row) return + element xhtml:tr { + simple2xhtml:recursion($node/node()) + } + + case element(tei:cell) return + element xhtml:td { + simple2xhtml:recursion($node/node()) + } default return simple2xhtml:recursion($node/node()) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 7191198b..498b7701 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -526,6 +526,19 @@ $log as xs:string) as node()* { else if($node/@type = "heading") then fontaneSimple:make-head($node, $uri, $log) + else if($node/@type = "list" + and $node//tei:seg[@type = "col"]) then + element tei:table { + $node/@*, + for $line in $node/tei:line[descendant::tei:seg[@type = "col"]] return + element tei:row { + for $seg in $line/descendant::tei:seg[@type = "col"] return + element tei:cell { + fontaneSimple:transform($seg/node(), $uri, $log) + } + } + } + else if($node/@type = "list" or $node/@type = "item") then element {QName("http://www.tei-c.org/ns/1.0", $node/@type)} { diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 312f9d4d..12a5d652 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -502,12 +502,12 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { case element(tei:item) return tidySimple:summarize-entries($node) -(: case element(tei:hi) return:) -(: tidySimple:summarize-entries($node):) - case element(tei:seg) return tidySimple:summarize-entries($node) + case element(tei:table) return + tidySimple:summarize-entries($node) + default return tidySimple:copy-element($node, "summarize") -- GitLab From c1770d74d25a1247a33a04ad19b75acf728407bf Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 29 Aug 2019 09:12:33 +0200 Subject: [PATCH 20/97] Implement 3.8.2.4.5 --- modules/fontane/edited-text/tidysimple.xqm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 12a5d652..0d521443 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -38,8 +38,6 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { => tidySimple:summarize() => tidySimple:summarize-headings() => tidySimple:sort-double-imgs() -(: => tidySimple:sort():) -(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):) let $header := tidySimple:get-Fontanes-sources($tei//tei:teiHeader[parent::tei:TEI]) => tidySimple:get-references-in-abstract() @@ -497,7 +495,7 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { tidySimple:summarize-entries($node) case element(tei:list) return - tidySimple:summarize-entries($node) + tidySimple:summarize-entries($node) case element(tei:item) return tidySimple:summarize-entries($node) @@ -510,7 +508,10 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { default return - tidySimple:copy-element($node, "summarize") + if($node/descendant::*[self::tei:milestone[@unit = "line"] or self::tei:rs or self::tei:list or self::tei:item or self::tei:seg or self::tei:table][@prev or @next]) then + tidySimple:copy-element($node, "summarize") + else + $node }; @@ -541,7 +542,7 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { $nodes-inbetween, tidySimple:apply-all-nexts($next-node)) else - () + tidySimple:summarize($node/node()) (: last of a virtual aggregation: exit point :) else if(not($node/@next)) then @@ -557,7 +558,7 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { $nodes-inbetween, tidySimple:apply-all-nexts($next-node)) else - () + tidySimple:summarize($node/node()) }; -- GitLab From d5b774b18c49ceae66e0b41f1129b5160e1d10c9 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 29 Aug 2019 13:59:04 +0200 Subject: [PATCH 21/97] Add first draft for dialogues, implement 3.21.8.1 --- modules/fontane/edited-text/simple2xhtml.xqm | 46 +++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index fd1ba874..db347b3d 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -56,7 +56,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () else element xhtml:span { - simple2xhtml:set-hs-info($node, ()), + simple2xhtml:set-hs-info($node, "text"), replace($node, " ,", ",") => replace(" \?", "?") => replace(" \.", ".") @@ -238,7 +238,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:milestone) return if($node/@unit = "line" - and $node/ancestor::tei:list and not($node/ancestor::tei:item)) then + and ($node/ancestor::tei:list and not($node/ancestor::tei:item) + or $node/ancestor::tei:seg[@type = "said"])) then element xhtml:br {} else if($node/@unit = "line") then @@ -413,6 +414,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } + else if($node/@type = "said") then + element xhtml:div { + attribute class {"nb-said"}, + simple2xhtml:recursion($node/node()) + } + else element xhtml:span { simple2xhtml:set-hs-info($node, "nb-seg"), @@ -514,6 +521,41 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } + case element(tei:gap) return + element xhtml:span { + if($node/@unit = "mm") then + attribute class {"gap-" || $node/@quantity} + else + attribute class {"gap"}, + switch ($node/@unit) + case "words" return + text{"X---x"} + case "cap_words" return + text{"X---x"} + case "uncap_words" return + text{"x---x"} + case "cap_word_chars" return + text{"X---x"} + case "uncap_word_chars" return + text{"x---x"} + case "lc_chars" return + text{ + for $iii in 1 to $node/@quantity return + "x" + } + case "uc_chars" return + text{ + for $iii in 1 to $node/@quantity return + "X" + } + case "chars" return + text{ + for $iii in 1 to $node/@quantity return + "X" + } + default return () + } + default return simple2xhtml:recursion($node/node()) }; -- GitLab From 0a19c1c29eaf5a303b6543a3243796dd1221fc9e Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 29 Aug 2019 15:36:40 +0200 Subject: [PATCH 22/97] Implement 3.21.10.1.1.1, fix bug in Beilagen --- modules/fontane/edited-text/simple2xhtml.xqm | 6 ++++++ modules/fontane/edited-text/tei2teisimple.xqm | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index db347b3d..859b7eef 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -398,6 +398,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () ) + else if($node/@type = "framed") then + element xhtmlspan { + simple2xhtml:set-hs-info($node, "nb-framed"), + simple2xhtml:recursion($node/node()) + } + else if($node[@rendition = ("vertical-align:super", "vertical-align:sub") and (following-sibling::*[1][self::tei:g[@ref ="#hb"]] diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 498b7701..574d36db 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -415,7 +415,8 @@ $log as xs:string) as node()* { else if($node/@type = "label" and (contains($node/@subtype, "Fontane") - or contains($node/@subtype, "Hersteller")) + or contains($node/@subtype, "Hersteller") + or contains($node/@subtype, "Firmen")) ) then fontaneSimple:make-div($node, $uri, $log) @@ -453,8 +454,8 @@ $log as xs:string) as node()* { if(matches($node/@style, "border-style:solid") and not(matches($node/@style, "border-radius")) and not($node/@rend = "border-style:house")) then - element tei:div { - attribute type {"frame"}, + element tei:seg { + attribute type {"framed"}, fontaneSimple:transform($node/node(), $uri, $log) } @@ -556,9 +557,6 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = "said" and $node/@prev) then - () - else if($node/@type = ("verse", "said")) then element tei:seg { attribute type {$node/@type}, -- GitLab From 7a1d2f0717135c004568eeb7f5d24874bec9a19b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 3 Sep 2019 09:30:25 +0200 Subject: [PATCH 23/97] Implement 3.19.2 --- modules/fontane/edited-text/simple2xhtml.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 859b7eef..7d75d0c9 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -429,7 +429,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else element xhtml:span { simple2xhtml:set-hs-info($node, "nb-seg"), -(: attribute style {$node/@rendition},:) + attribute style {$node/@rendition}, simple2xhtml:recursion($node/node()) } -- GitLab From e56af3cd183f15b066714e7a8fe92825ba3c4f92 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 3 Sep 2019 09:47:16 +0200 Subject: [PATCH 24/97] Implement 3.20 --- modules/fontane/edited-text/simple2xhtml.xqm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 7d75d0c9..43a82e38 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -63,6 +63,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { => replace(" ;", ";") => replace("@@", " ") => replace("@P", "") + => replace("@", "") => replace("  ", " ") => replace(":", ": ") => replace(" “", "“") @@ -128,6 +129,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { element xhtml:div { if($node/@type = "label") then simple2xhtml:set-hs-info($node, "nb-label") + + else if($node/@type = "additional") then + simple2xhtml:set-hs-info($node, "nb-additional") + else simple2xhtml:set-hs-info($node, ()), simple2xhtml:recursion($node/node()) -- GitLab From f8c4e34c896e85af611ac01aac1f9d647ecc78f8 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 5 Sep 2019 13:53:12 +0200 Subject: [PATCH 25/97] Remove outdated modules --- modules/fontane/edited-text/etTransfo.xqm | 1 - modules/fontane/edited-text/prepcom.xqm | 1 - modules/fontane/edited-text/tidysimple.xqm | 1 - 3 files changed, 3 deletions(-) diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index c28b1a31..0cbc286d 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -24,7 +24,6 @@ import module namespace fsort="http://fontane-nb.dariah.eu/sort" at "sort.xqm"; import module namespace functx = "http://www.functx.com"; import module namespace macro-sort="http://fontane-nb.dariah.eu/macro-sort" at "macro-sort.xqm"; import module namespace prepCom="http://fontane-nb.dariah.eu/prepCom" at "prepcom.xqm"; -import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm"; import module namespace simple2xhtml="http://fontane-nb.dariah.eu/simple2xhtml" at "simple2xhtml.xqm"; import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "tidysimple.xqm"; diff --git a/modules/fontane/edited-text/prepcom.xqm b/modules/fontane/edited-text/prepcom.xqm index 033f2581..0cb70fd9 100644 --- a/modules/fontane/edited-text/prepcom.xqm +++ b/modules/fontane/edited-text/prepcom.xqm @@ -17,7 +17,6 @@ declare namespace xi="http://www.w3.org/2001/XInclude"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; import module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple" at "tei2teisimple.xqm"; import module namespace functx = "http://www.functx.com"; -import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm"; import module namespace simple2xhtml="http://fontane-nb.dariah.eu/simple2xhtml" at "simple2xhtml.xqm"; import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "tidysimple.xqm"; diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 0d521443..58a0f318 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -20,7 +20,6 @@ declare namespace test="http://exist-db.org/xquery/xqsuite"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; import module namespace functx="http://www.functx.com"; import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at "index-info.xqm"; -import module namespace presort="http://fontane-nb.dariah.eu/presort" at "presort.xqm"; import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm"; -- GitLab From 83707c5dafd803e224be4e515565d37fe72fb1a1 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 6 Sep 2019 08:35:01 +0200 Subject: [PATCH 26/97] Remove error logs in single transformation (leads to duplications) --- modules/fontane/edited-text/etTransfo.xqm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index 0cbc286d..cef61927 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -92,8 +92,7 @@ declare function etTransfo:transform-single-nb($uri as xs:string) as xs:string* } catch * { etTransfo:add-log-entry($log, "ETTRANSFO08: Couldn't transform TEI. ") }, - etTransfo:tidy-logs(), - etTransfo:report-errors()) + etTransfo:tidy-logs()) }; -- GitLab From 50f5ac36936540edb9741b44451839ce47c0ec38 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 6 Sep 2019 11:23:45 +0200 Subject: [PATCH 27/97] Implement 3.21.8.3 --- modules/fontane/edited-text/simple2xhtml.xqm | 73 ++++++++++--------- modules/fontane/edited-text/tei2teisimple.xqm | 13 ++++ 2 files changed, 51 insertions(+), 35 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 43a82e38..5c79b948 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -151,7 +151,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:hi) return - if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable", "missing-hyphen")]) then + if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable", "missing-hyphen", "supplied")]) then element xhtml:span { simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) @@ -419,9 +419,9 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/@type = "integration") then simple2xhtml:make-integration($node) - else if($node/@type = "missing-hyphen") then + else if($node/@type = ("missing-hyphen", "supplied")) then element xhtml:span { - simple2xhtml:set-hs-info($node, "nb-missing-hyphen"), + simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) } @@ -533,38 +533,41 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:gap) return - element xhtml:span { - if($node/@unit = "mm") then - attribute class {"gap-" || $node/@quantity} - else - attribute class {"gap"}, - switch ($node/@unit) - case "words" return - text{"X---x"} - case "cap_words" return - text{"X---x"} - case "uncap_words" return - text{"x---x"} - case "cap_word_chars" return - text{"X---x"} - case "uncap_word_chars" return - text{"x---x"} - case "lc_chars" return - text{ - for $iii in 1 to $node/@quantity return - "x" - } - case "uc_chars" return - text{ - for $iii in 1 to $node/@quantity return - "X" - } - case "chars" return - text{ - for $iii in 1 to $node/@quantity return - "X" - } - default return () + if($node/following-sibling::*[1][self::tei:seg[@type = "supplied"]]) then + () + else + element xhtml:span { + if($node/@unit = "mm") then + attribute class {"gap-" || $node/@quantity} + else + attribute class {"gap"}, + switch ($node/@unit) + case "words" return + text{"X---x"} + case "cap_words" return + text{"X---x"} + case "uncap_words" return + text{"x---x"} + case "cap_word_chars" return + text{"X---x"} + case "uncap_word_chars" return + text{"x---x"} + case "lc_chars" return + text{ + for $iii in 1 to $node/@quantity return + "x" + } + case "uc_chars" return + text{ + for $iii in 1 to $node/@quantity return + "X" + } + case "chars" return + text{ + for $iii in 1 to $node/@quantity return + "X" + } + default return () } default return diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 574d36db..ddeaf59e 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -432,6 +432,9 @@ $log as xs:string) as node()* { case element(tei:gap) return fontaneSimple:copy-element($node, $uri, $log) + case element(tei:supplied) return + fontaneSimple:mark-supplied($node, $uri, $log) + case element(tei:metamark) return if($node/@function = "integrate" or $node/@function = "authorial_note") then @@ -1037,6 +1040,16 @@ element(tei:seg) { } }; +declare function fontaneSimple:mark-supplied($node as element(tei:supplied), $uri as xs:string, $log as xs:string) as +element(tei:seg) { + element tei:seg { + attribute type {"supplied"}, + , + fontaneSimple:transform($node/node(), $uri, $log), + + } +}; + (:~ In this first serialization step the beginning and end of line groups are : simply marked with milestones, which are expanded to a full tei:lg in the -- GitLab From c675f05a2e1e24a1faa4213d1ef12d6a0e091628 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 6 Sep 2019 14:05:45 +0200 Subject: [PATCH 28/97] Add first draft for 3.21.11.3 --- modules/fontane/edited-text/simple2xhtml.xqm | 23 ++++++++++++++----- modules/fontane/edited-text/tei2teisimple.xqm | 4 ++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 5c79b948..fd2df941 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -127,15 +127,26 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } else element xhtml:div { - if($node/@type = "label") then - simple2xhtml:set-hs-info($node, "nb-label") - - else if($node/@type = "additional") then - simple2xhtml:set-hs-info($node, "nb-additional") + if($node/@type = ("label", "additional", "marked_off")) then + simple2xhtml:set-hs-info($node, "nb-" || $node/@type) else simple2xhtml:set-hs-info($node, ()), - simple2xhtml:recursion($node/node()) + if($node/@type = "marked_off") then + element xhtml:div { + attribute class {"nb-editorial"}, + text{""} + } + else + (), + simple2xhtml:recursion($node/node()), + if($node/@type = "marked_off") then + element xhtml:div { + attribute class {"nb-editorial"}, + text{""} + } + else + () } case element(tei:expan) return diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index ddeaf59e..b876d270 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -335,7 +335,7 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = ("integration", "editorial-label", "col")) then + else if($node/@type = ("integration", "editorial-label", "col", "marked_off")) then element tei:seg { $node/@*, fontaneSimple:transform($node/node(), $uri, $log) @@ -472,7 +472,7 @@ $log as xs:string) as node()* { () else if($node/@type = "marked_off") then - element tei:seg { + element tei:div { $node/@type, $node/@xml:id, fontaneSimple:transform($node/node(), $uri, $log) -- GitLab From d7ba832386fb600c552f62eb994ebde76153c439 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 6 Sep 2019 15:49:15 +0200 Subject: [PATCH 29/97] Implement 3.21.19.1.3 --- modules/fontane/edited-text/simple2xhtml.xqm | 5 +-- modules/fontane/edited-text/tei2teisimple.xqm | 35 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index fd2df941..444c0b80 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -162,7 +162,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:hi) return - if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable", "missing-hyphen", "supplied")]) then + if($node/ancestor::tei:seg[@type = ("reduplication", "missing-syllable", "missing-hyphen", "supplied")] + or $node[@type = "blue-underlined"]) then element xhtml:span { simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) @@ -430,7 +431,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/@type = "integration") then simple2xhtml:make-integration($node) - else if($node/@type = ("missing-hyphen", "supplied")) then + else if($node/@type = ("missing-hyphen", "supplied", "blue-underlined")) then element xhtml:span { simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index b876d270..175645f4 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -273,6 +273,13 @@ $log as xs:string) as node()* { else if($node/@type = "heading") then fontaneSimple:make-head($node, $uri, $log) + else if($node[@style = "text-decoration:underline" and @rend = "underline-medium:blue_pencil"]) then + element tei:seg { + attribute type {"blue-underlined"}, + fontaneSimple:transform($node/node(), $uri, $log) + } + + else if(matches($node/@style, "underline") and not(matches($node/@style, "vertical-align"))) then fontaneSimple:transform($node/node(), $uri, $log) @@ -345,17 +352,25 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) case element(tei:hi) return - (element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - fontaneSimple:transform($node/node(), $uri, $log) - }, - if(not($node/@prev or $node/@next) - and $node/following::node()[1][self::text()][normalize-space(.) = ""] - and $node/following::*[1][self::tei:hi]) then - text{"@"} + if($node/ancestor::tei:seg[@style = "text-decoration:underline" and @rend = "underline-medium:blue_pencil"] + or $node/descendant::tei:seg[@style = "text-decoration:underline" and @rend = "underline-medium:blue_pencil"]) then + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + attribute type {"blue-underlined"}, + fontaneSimple:transform($node/node(), $uri, $log) + } else - () - ) + (element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + fontaneSimple:transform($node/node(), $uri, $log) + }, + if(not($node/@prev or $node/@next) + and $node/following::node()[1][self::text()][normalize-space(.) = ""] + and $node/following::*[1][self::tei:hi]) then + text{"@"} + else + () + ) (: TODO if $node/@type = "highlighted" then make a hi[@type = "vertical-mark"] in the second stage of creating the -- GitLab From 964bc7c2470cf716e76b7d54470718c8fac2a9dd Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 16 Sep 2019 09:47:49 +0200 Subject: [PATCH 30/97] Implement 3.21.10.2.2.2.1.1 horizontal end lines --- modules/fontane/edited-text/simple2xhtml.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 444c0b80..9942ef88 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -330,7 +330,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } - else if($node/@type = ("short-paragraph-line", "sum", "double-sum", "difference")) then + else if($node/@type = ("short-paragraph-line", "sum", "double-sum", "difference", "long-end-line")) then element xhtml:div { attribute class {$node/@type} } -- GitLab From 2a8a34a0bf6763ac1f2ea6645ee80ccae1f08a68 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 16 Sep 2019 10:53:46 +0200 Subject: [PATCH 31/97] Implement 3.21.10.2.2.2.1.4 horizontal curly bracket --- modules/fontane/edited-text/simple2xhtml.xqm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 9942ef88..6315fff8 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -330,11 +330,20 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } - else if($node/@type = ("short-paragraph-line", "sum", "double-sum", "difference", "long-end-line")) then + else if($node/@type = ("short-paragraph-line", "sum", "double-sum", + "difference", "long-end-line")) then element xhtml:div { attribute class {$node/@type} } + else if($node/@type = "bottom-brace") then + (
, + element xhtml:span { + attribute class {$node/@type}, + text{"⏟"} + }, +
) + else if($node/@type = "paragraph" and $node/string = "z") then (element xhtml:br {}, element xhtml:div { -- GitLab From 8c3b0e82ce65d985f93b738f4a35c2ad913f8ffe Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 16 Sep 2019 11:28:39 +0200 Subject: [PATCH 32/97] Implement lines and brackets at the end of semantic units --- modules/fontane/edited-text/simple2xhtml.xqm | 13 ++++++++----- modules/fontane/edited-text/tei2teisimple.xqm | 4 +--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 6315fff8..21dc8a2d 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -331,7 +331,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } else if($node/@type = ("short-paragraph-line", "sum", "double-sum", - "difference", "long-end-line")) then + "difference", "long-end-line", "end-line", "short-paragraph-line-double")) then element xhtml:div { attribute class {$node/@type} } @@ -344,11 +344,14 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { },
) - else if($node/@type = "paragraph" and $node/string = "z") then - (element xhtml:br {}, + else if($node/@type = "paragraph") then element xhtml:div { - attribute class {"nb-paragraph"} - }) + attribute class {"nb-paragraph-line-special-characters"}, + if($node/string() = "z") then + () + else + simple2xhtml:recursion($node/node()) + } else simple2xhtml:recursion($node/node()) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 175645f4..fcb23e12 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -661,9 +661,7 @@ $log as xs:string) as node()* { case "Schlusslinie; horizontale Halbschleife von links oben nach rechts" return attribute type {"long-end-line"} case "horizontale einfache Schlusslinie (gewellt)" return - attribute type {"long-end-line-wavy"} - case "Schlusslinien; horizontale Schleife von links oben nach rechts unten" return - attribute type {"bottom-brace-short"} + attribute type {"long-end-line"} default return attribute type {"end-line"} } -- GitLab From 1b33f5cfeec17830dbf6181893afb72529a8785c Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 16 Sep 2019 13:06:40 +0200 Subject: [PATCH 33/97] Implement vertical marks, verse markers and spaces --- modules/fontane/edited-text/simple2xhtml.xqm | 24 +++++++++++++++++++ modules/fontane/edited-text/tei2teisimple.xqm | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 21dc8a2d..98ecd8c0 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -168,6 +168,13 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) } + + else if($node/@type = "vertical-mark") then + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-" || $node/@type), + simple2xhtml:recursion($node/node()) + } + else (text{" "}, element xhtml:span { @@ -330,6 +337,15 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } + else if($node/@type = "verse_marker") then + element xhtml:seg { + attribute class {"nb-" || $node/@type}, + if($node/@rend = "pipe") then + text{"|"} + else + text{"/"} + } + else if($node/@type = ("short-paragraph-line", "sum", "double-sum", "difference", "long-end-line", "end-line", "short-paragraph-line-double")) then element xhtml:div { @@ -594,6 +610,14 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { default return () } + case element(tei:space) return + if($node/@type = ("pause", "placeholder")) then + element xhtml:span { + attribute class {"nb-" || $node/@type} + } + else + () + default return simple2xhtml:recursion($node/node()) }; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index fcb23e12..8486d81d 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -359,6 +359,7 @@ $log as xs:string) as node()* { attribute type {"blue-underlined"}, fontaneSimple:transform($node/node(), $uri, $log) } + else (element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, @@ -457,7 +458,7 @@ $log as xs:string) as node()* { $node/@* } else if($node/@function = ("placeholder", "etc.", "caret", - "footnote-mark", "footnotes", "ellipsis", "paragraph")) then + "footnote-mark", "footnotes", "ellipsis", "paragraph", "verse_marker")) then element tei:ab { attribute type {$node/@function}, fontaneSimple:transform($node/node(), $uri, $log) -- GitLab From 09c56f9a200df0ade53dbec18e2f14935a05f6b0 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 17 Sep 2019 08:38:04 +0200 Subject: [PATCH 34/97] Keep info about verse marker rendition --- modules/fontane/edited-text/tei2teisimple.xqm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 8486d81d..a2b7a304 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -461,6 +461,10 @@ $log as xs:string) as node()* { "footnote-mark", "footnotes", "ellipsis", "paragraph", "verse_marker")) then element tei:ab { attribute type {$node/@function}, + if($node/@function = "verse_marker") then + attribute rend {$node/@rend} + else + (), fontaneSimple:transform($node/node(), $uri, $log) } else -- GitLab From c539945662cd10ed166c5be8df7bed074e35fc97 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 17 Sep 2019 10:33:18 +0200 Subject: [PATCH 35/97] Further implementation of requirements for prints --- modules/fontane/edited-text/simple2xhtml.xqm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 98ecd8c0..9a5d387a 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -471,6 +471,20 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } + else if(matches($node/@rendition, "smallcaps")) then + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-smallcaps"), + attribute style {$node/@rendition}, + simple2xhtml:recursion($node/node()) + } + + else if($node/@type = "initials") then + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-initials"), + attribute style {$node/@rendition}, + simple2xhtml:recursion($node/node()) + } + else element xhtml:span { simple2xhtml:set-hs-info($node, "nb-seg"), -- GitLab From a0c5ed39a4848aa5723160caca8c2376fcd1eccc Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 19 Sep 2019 15:59:38 +0200 Subject: [PATCH 36/97] Further work on requirements --- modules/fontane/edited-text/simple2xhtml.xqm | 149 +++++++++++------- modules/fontane/edited-text/sort.xqm | 43 ++++- modules/fontane/edited-text/tei2teisimple.xqm | 22 ++- 3 files changed, 144 insertions(+), 70 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 9a5d387a..8231117f 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -126,28 +126,30 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } else - element xhtml:div { - if($node/@type = ("label", "additional", "marked_off")) then - simple2xhtml:set-hs-info($node, "nb-" || $node/@type) - - else - simple2xhtml:set-hs-info($node, ()), - if($node/@type = "marked_off") then + (if($node/@type = "marked_off") then element xhtml:div { attribute class {"nb-editorial"}, text{""} } else (), - simple2xhtml:recursion($node/node()), - if($node/@type = "marked_off") then + element xhtml:div { + if($node/@type = ("label", "additional", "marked_off")) then + simple2xhtml:set-hs-info($node, "nb-" || $node/@type) + + else + simple2xhtml:set-hs-info($node, ()), + simple2xhtml:recursion($node/node()) + + }, + if($node/@type = "marked_off") then element xhtml:div { attribute class {"nb-editorial"}, text{""} } else () - } + ) case element(tei:expan) return element xhtml:span { @@ -263,7 +265,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:milestone) return if($node/@unit = "line" and ($node/ancestor::tei:list and not($node/ancestor::tei:item) - or $node/ancestor::tei:seg[@type = "said"])) then + or $node/ancestor::tei:seg[@type = "said"] + or $node/ancestor::tei:div[@type = "edited_text"])) then element xhtml:br {} else if($node/@unit = "line") then @@ -319,7 +322,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ) case element(tei:ab) return - if($node/@type = "sketch" + if($node/@type = "sketch"") then" and $node/descendant::tei:figure) then element xhtml:table { attribute class {"nb-sketch"}, @@ -347,7 +350,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } else if($node/@type = ("short-paragraph-line", "sum", "double-sum", - "difference", "long-end-line", "end-line", "short-paragraph-line-double")) then + "difference", "long-end-line", "end-line", "short-paragraph-line-double", + "footnotes")) then element xhtml:div { attribute class {$node/@type} } @@ -369,6 +373,9 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) } + else if($node/@type = "authorial_note") then + text{"authorial note"} + else simple2xhtml:recursion($node/node()) @@ -459,7 +466,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/@type = "integration") then simple2xhtml:make-integration($node) - else if($node/@type = ("missing-hyphen", "supplied", "blue-underlined")) then + else if($node/@type = ("missing-hyphen", "supplied", "blue-underlined", "highlighted-area")) then element xhtml:span { simple2xhtml:set-hs-info($node, "nb-" || $node/@type), simple2xhtml:recursion($node/node()) @@ -512,19 +519,14 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () case element(tei:note) return - if($node/@type = "editorial") then + if($node/@type = ("editorial", "authorial")) then element xhtml:span { - attribute class {"editorial-note"}, + attribute class {$node/@type || "-note"}, simple2xhtml:recursion($node/node()) } - else if($node/@subtype = "footnote") then + else if($node/@subtype = ("footnote", "revision")) then element xhtml:div { - attribute class {"nb-footnote"}, - simple2xhtml:recursion($node/node()) - } - else if($node/@subtype = "revision") then - element xhtml:div { - attribute class {"nb-revision"}, + attribute class {"nb-" || $node/@subtype}, simple2xhtml:recursion($node/node()) } else @@ -804,7 +806,8 @@ as attribute() { declare function simple2xhtml:make-integration($node as element(tei:seg)) { - let $bracket := $node//tei:ab[@function = "integrate"] + let $bracket := $node//tei:ab[@function = ("integrate", "authorial_note")] + let $orientation := substring-after($bracket/@rend, "bracket_") (: target is the side where the pointy end of the bracket goes. corresp is the side where bracket faces to. @@ -814,6 +817,9 @@ declare function simple2xhtml:make-integration($node as element(tei:seg)) { let $corresp-id := replace($bracket/@corresp, "#", "") let $corresp := $node//*[@xml:id = $corresp-id] + let $bla := util:log-system-out($corresp) + let $bla := util:log-system-out($target) + let $lines-target := count($target//tei:milestone[@unit = "line"]) let $lines-corresp := count($corresp//tei:milestone[@unit = "line"]) let $max-number-of-lines := @@ -825,41 +831,74 @@ declare function simple2xhtml:make-integration($node as element(tei:seg)) { return - element xhtml:table { - attribute class {"integration"}, - element xhtml:tr { - element xhtml:td { - attribute class {"integration-left"}, - if($bracket/@rend = "bracket_right") then - simple2xhtml:recursion($corresp/node()) - else if($bracket/@rend = "bracket_left") then - simple2xhtml:recursion($target/node()) - else - () - }, - element xhtml:td { - attribute class {"integration-bracket"}, - attribute style {"font-size: " || $bracket-size || "pt;"}, - if($bracket/@rend = "bracket_right") then - text{"}"} - else if($bracket/@rend = "bracket_left") then - text{"{"} - else - () - }, - element xhtml:td { - attribute class {"integration-right"}, - if($bracket/@rend = "bracket_right") then - simple2xhtml:recursion($target/node()) - else if($bracket/@rend = "bracket_left") then - simple2xhtml:recursion($corresp/node()) - else - () - } + if($orientation = "bottom") then + simple2xhtml:make-bottom-bracket-integration-table($corresp, $target) + else + simple2xhtml:make-lr-bracket-integration-table($orientation, $corresp, $target, $bracket-size) + + + +}; + +declare function simple2xhtml:make-lr-bracket-integration-table($orientation as xs:string, +$corresp as node()*, $target as node()*, $bracket-size as xs:integer) { + element xhtml:table { + attribute class {"integration"}, + element xhtml:tr { + element xhtml:td { + attribute class {"integration-left"}, + if($orientation = "bracket_right") then + simple2xhtml:recursion($corresp/node()) + else if($orientation = "bracket_left") then + simple2xhtml:recursion($target/node()) + else + () + }, + element xhtml:td { + attribute class {"integration-bracket"}, + attribute style {"font-size: " || $bracket-size || "pt;"}, + if($orientation = "bracket_right") then + text{"}"} + else if($orientation = "bracket_left") then + text{"{"} + else + () + }, + element xhtml:td { + attribute class {"integration-right"}, + if($orientation = "bracket_right") then + simple2xhtml:recursion($target/node()) + else if($orientation = "bracket_left") then + simple2xhtml:recursion($corresp/node()) + else + () } } + } }; +declare function simple2xhtml:make-bottom-bracket-integration-table($corresp as node()*, +$target as node()*) { + element xhtml:table { + attribute class {"integration integration-bottom"}, + element xhtml:tr { + element xhtml:td { + simple2xhtml:recursion($corresp/node()) + } + }, + element xhtml:tr { + element xhtml:td { + attribute class {"integration-bottom-bracket"}, + text{"⏟"} + } + }, + element xhtml:tr { + element xhtml:td { + simple2xhtml:recursion($target/node()) + } + } + } +}; declare function simple2xhtml:tidy($nodes as node()*) as node()* { for $node in $nodes return diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 1f56759d..a858d8ef 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -27,10 +27,11 @@ declare function fsort:main($tei as node()*, $log as xs:string) as element(tei:T let $prepared := fsort:enhance-handshifts($prepared, $log) let $fully-sorted := fsort:sort($prepared, $log) let $integrations := fsort:sort-integrations($fully-sorted, $log) + let $highlighted := fsort:sort-highlighted-areas($integrations, $log) let $id := $tei/@id - let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $integrations) - return $integrations + let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $highlighted) + return $highlighted }; @@ -63,6 +64,9 @@ declare function fsort:sort($nodes as node()*, $log as xs:string) { case element(tei:rs) return fsort:default-return($node, $log) + case element(tei:abbr) return + fsort:default-return($node, $log) + default return fsort:copy-node($node, "sort", $log) }; @@ -202,6 +206,8 @@ declare function fsort:copy-node($node as node(), $flag as xs:string, $log as xs fsort:enhance-handshifts($node/node(), $log) else if($flag = "sort-integrations") then fsort:sort-integrations($node/node(), $log) + else if($flag = "sort-highlighted") then + fsort:sort-highlighted-areas($node/node(), $log) else error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) } @@ -411,7 +417,7 @@ declare function fsort:sort-integrations($nodes as node()*, $log as xs:string) a for $node in $nodes return if($node/@xml:id) then let $id := $node/@xml:id - let $metamarks := $node/root()//tei:metamark[@function = "integrate"] + let $metamarks := $node/root()//tei:metamark[@function = ("integrate", "authorial_note")] let $linking-node-corresp := $metamarks[substring-after(@corresp, "#") = $id] let $linking-node-target := $metamarks[substring-after(@target, "#") = $id] @@ -438,3 +444,34 @@ declare function fsort:sort-integrations($nodes as node()*, $log as xs:string) a else fsort:copy-node($node, "sort-integrations", $log) }; + + +declare function fsort:sort-highlighted-areas($nodes as node()*, $log as xs:string) +as node()* { + for $node in $nodes return + typeswitch ($node) + case text() return + $node + + case comment() return + $node + + case element(tei:mod) return + if($node/@type = "highlighted" and matches($node/@hand, "Fontane")) then + element tei:seg { + attribute type {"highlighted-area"}, + $node/following::*[. << following::tei:anchor["#" || @xml:id = $node/@spanTo]] + } + else + fsort:copy-node($node, "sort-highlighted", $log) + default return + if($node/preceding::tei:mod[@type = "highlighted"][1][matches(@hand, "Fontane")]) then + let $id := replace($node/preceding::tei:mod[@type = "highlighted"][1][matches(@hand, "Fontane")]/@spanTo, "#", "") + return + if($node/following::tei:anchor[@xml:id = $id]) then + () + else + fsort:copy-node($node, "sort-highlighted", $log) + else + fsort:copy-node($node, "sort-highlighted", $log) +}; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index a2b7a304..7d201da6 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -292,6 +292,7 @@ $log as xs:string) as node()* { else if($node/@type = "initials" or $node/@type = "monogram" or $node/@type = "multiphrase" + or $node/@type = "highlighted-area" or $node/@xml:lang) then (fontaneSimple:copy-element($node, $uri, $log), @@ -452,8 +453,7 @@ $log as xs:string) as node()* { fontaneSimple:mark-supplied($node, $uri, $log) case element(tei:metamark) return - if($node/@function = "integrate" - or $node/@function = "authorial_note") then + if($node/@function = ("integrate", "authorial_note")) then element tei:ab { $node/@* } @@ -510,8 +510,7 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = "illustration" - or $node/@type = "printed_illustration") then + else if($node/@type = ("illustration", "printed_illustration")) then if(not($node//tei:figure/parent::tei:del)) then element tei:ab { (if($node/child::tei:zone[@type = "illustration"]) then @@ -535,13 +534,13 @@ $log as xs:string) as node()* { ), attribute width {$node/@lrx - $node/@ulx || "cm"}, attribute height {$node/@lry - $node/@uly || "cm"}, + $node/@xml:id, fontaneSimple:transform($node/node(), $uri, $log) } else () - else if($node/parent::tei:zone/@type = "illustration" - or $node/parent::tei:zone/@type = "printed_illustration") then + else if($node/parent::tei:zone/@type = ("illustration", "printed_illustration")) then element tei:seg { attribute type {"caption"}, fontaneSimple:transform($node/node(), $uri, $log) @@ -563,8 +562,7 @@ $log as xs:string) as node()* { } } - else if($node/@type = "list" - or $node/@type = "item") then + else if($node/@type = ("list", "item")) then element {QName("http://www.tei-c.org/ns/1.0", $node/@type)} { $node/(@xml:id, @subtype, @rendition, @prev, @next), if($node/@rend) then @@ -574,9 +572,9 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = "dialogue") then + else if($node/@type = ("dialogue", "edited_text")) then element tei:div { - $node/@type, + $node/@*, fontaneSimple:transform($node/node(), $uri, $log) } @@ -707,7 +705,7 @@ $log as xs:string) as node()* { else if($node/ancestor::tei:surface[@next or @prev]) then fontaneSimple:make-img($node, $uri, $log,"double") - else if($node/ancestor::tei:zone[@type = "illustration"]) then + else if($node/ancestor::tei:zone[@type = ("illustration", "printed_illustration")]) then fontaneSimple:make-img($node, $uri, $log, "") else @@ -715,7 +713,7 @@ $log as xs:string) as node()* { case element(tei:note) return if($node/@type = "authorial" - and not($node/@subtype = ("footnote", "revision"))) then + and not($node/@subtype = ("footnote", "revision", "text"))) then () else fontaneSimple:copy-element($node, $uri, $log) -- GitLab From fd67031c3766d229774ce81ee39ebf3ab1b2e52f Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 19 Sep 2019 16:01:07 +0200 Subject: [PATCH 37/97] Remove surplus module --- modules/fontane/edited-text/etTransfo.xqm | 10 -- modules/fontane/edited-text/macro-sort.xqm | 105 --------------------- 2 files changed, 115 deletions(-) delete mode 100644 modules/fontane/edited-text/macro-sort.xqm diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index cef61927..ee675aee 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -22,7 +22,6 @@ import module namespace config="http://textgrid.de/ns/SADE/config" at "../../con import module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple" at "tei2teisimple.xqm"; import module namespace fsort="http://fontane-nb.dariah.eu/sort" at "sort.xqm"; import module namespace functx = "http://www.functx.com"; -import module namespace macro-sort="http://fontane-nb.dariah.eu/macro-sort" at "macro-sort.xqm"; import module namespace prepCom="http://fontane-nb.dariah.eu/prepCom" at "prepcom.xqm"; import module namespace simple2xhtml="http://fontane-nb.dariah.eu/simple2xhtml" at "simple2xhtml.xqm"; import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "tidysimple.xqm"; @@ -191,18 +190,9 @@ declare function etTransfo:create-htmls($showcase as xs:string) as xs:string* { : @param $tei The current notebook as element(tei:TEI) :) declare function etTransfo:transform-tei($tei as element(tei:TEI), $log as xs:string) { -(: macro-sort:main($tei, $tei/@id):) -(: let $macro-sorted :=:) -(: try {:) -(: macro-sort:main($tei, $tei/@id):) -(: } catch * {:) -(: etTransfo:add-log-entry($log, "ETTRANSFO14: Error while macro sorting this notebook. Reason: " ||:) -(: concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description)):) -(: }:) let $sorted := try { fsort:main($tei, $log) -(: fsort:main($macro-sorted, $log) :) } catch * { etTransfo:add-log-entry($log, "ETTRANSFO09: Error while sorting this notebook. Reason: " || concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description)) diff --git a/modules/fontane/edited-text/macro-sort.xqm b/modules/fontane/edited-text/macro-sort.xqm deleted file mode 100644 index 4f4deaa8..00000000 --- a/modules/fontane/edited-text/macro-sort.xqm +++ /dev/null @@ -1,105 +0,0 @@ -xquery version "3.1"; - -(:~ - : This module serves for getting the writing chronology on a macro level right. - : - :) - -module namespace macro-sort="http://fontane-nb.dariah.eu/macro-sort"; - -import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; - -declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace xi="http://www.w3.org/2001/XInclude"; - - - -declare function macro-sort:main($tei as node()*, $uri as xs:string) as node()* { - let $header := $tei//tei:teiHeader - let $sorted := macro-sort:sort($tei//tei:sourceDoc) -(: let $cleared := macro-sort:clear($sorted):) - let $cleared := $sorted - - let $final-tei := - element tei:TEI { - $header, - $cleared - } - - let $store := xmldb:store($config:data-root || "/print/xml/", $uri || "-macrosort.xml", $final-tei) - - return - $final-tei - }; - - declare function macro-sort:sort($nodes as node()*) as node()* { - for $node in $nodes return - typeswitch ($node) - - case text() return - $node - - case comment() return - $node - - case element(tei:milestone) return - if($node/@unit = "section") then - let $end-point-id := replace($node/@spanTo, "#", "") - let $end-point := $node/root()//tei:anchor[@xml:id = $end-point-id] - let $number := substring-after($node/@type, "Text_") - let $handshift := $node/preceding::tei:milestone[@unit = "handshift"][1] - - return - element tei:div { - attribute n {$number}, -(: $node/(@* except @spanTo),:) - $node/@*, - $handshift, - (: all nodes on the current surface :) - $node/following-sibling::node()[. << $end-point], - $node/../following-sibling::node()[. << $end-point], - (: all complete surfaces before the anchor :) - $node/ancestor::tei:surface/following-sibling::tei:surface[. << $end-point], - (: all elements on the surface that contains the anchor which are before the anchor :) - $node/ancestor::tei:surface/following-sibling::tei:surface[descendant::tei:anchor[@xml:id = $end-point-id]]//tei:anchor[@xml:id = $end-point-id]/preceding-sibling::* - } - - else - macro-sort:copy-element($node) - - default return - let $section-marker := $node/preceding::tei:milestone[@unit = "section"][1] - let $end-point-id := replace($section-marker/@spanTo, "#", "") - let $end-point := $node/root()//tei:anchor[@xml:id = $end-point-id] - - return - if($node[. >> $section-marker and . << $end-point]) then - () - else - macro-sort:copy-element($node) - }; - - -declare function macro-sort:copy-element($node as element(*)) as element(*) { - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - macro-sort:sort($node/node()) - } -}; - -declare function macro-sort:clear($nodes as node()*) as node()* { - for $node in $nodes return - typeswitch ($node) - - case text() return - $node - - case comment() return - $node - - default return - if($node/@outside-section = "true") then - () - else - $node -}; -- GitLab From 3097356d2af77e50210fa801e08d62279d8a97a5 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Fri, 20 Sep 2019 11:40:26 +0200 Subject: [PATCH 38/97] Fix bug --- modules/fontane/edited-text/simple2xhtml.xqm | 16 ++++++---------- modules/fontane/edited-text/tei2teisimple.xqm | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 8231117f..04c6293c 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -817,9 +817,6 @@ declare function simple2xhtml:make-integration($node as element(tei:seg)) { let $corresp-id := replace($bracket/@corresp, "#", "") let $corresp := $node//*[@xml:id = $corresp-id] - let $bla := util:log-system-out($corresp) - let $bla := util:log-system-out($target) - let $lines-target := count($target//tei:milestone[@unit = "line"]) let $lines-corresp := count($corresp//tei:milestone[@unit = "line"]) let $max-number-of-lines := @@ -829,7 +826,6 @@ declare function simple2xhtml:make-integration($node as element(tei:seg)) { $lines-corresp let $bracket-size := 12 * ($max-number-of-lines + 1) - return if($orientation = "bottom") then simple2xhtml:make-bottom-bracket-integration-table($corresp, $target) @@ -847,9 +843,9 @@ $corresp as node()*, $target as node()*, $bracket-size as xs:integer) { element xhtml:tr { element xhtml:td { attribute class {"integration-left"}, - if($orientation = "bracket_right") then + if($orientation = "right") then simple2xhtml:recursion($corresp/node()) - else if($orientation = "bracket_left") then + else if($orientation = "left") then simple2xhtml:recursion($target/node()) else () @@ -857,18 +853,18 @@ $corresp as node()*, $target as node()*, $bracket-size as xs:integer) { element xhtml:td { attribute class {"integration-bracket"}, attribute style {"font-size: " || $bracket-size || "pt;"}, - if($orientation = "bracket_right") then + if($orientation = "right") then text{"}"} - else if($orientation = "bracket_left") then + else if($orientation = "left") then text{"{"} else () }, element xhtml:td { attribute class {"integration-right"}, - if($orientation = "bracket_right") then + if($orientation = "right") then simple2xhtml:recursion($target/node()) - else if($orientation = "bracket_left") then + else if($orientation = "left") then simple2xhtml:recursion($corresp/node()) else () diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 7d201da6..1a134a20 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -77,6 +77,7 @@ $log as xs:string) as node()* { or $node/ancestor::tei:figDesc or $node/ancestor::tei:desc[@type = "edited_text"] or $node/ancestor::tei:note[@type = "editorial"] + or $node/ancestor::tei:note[@type = "authorial" and @subtype = ("footnote", "revision", "text")] or $node/ancestor::tei:seg[@type = "editorial-label"] or $node/ancestor::tei:ref[not(matches(@target, "getty") or matches(@target, "xpath"))] or $node/ancestor::tei:seg[@type = "heading"]) then -- GitLab From 322522e8c18976e3dd018d023181ad1da35f9839 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 23 Sep 2019 10:47:24 +0200 Subject: [PATCH 39/97] Implement transposition of words --- modules/fontane/edited-text/sort.xqm | 99 ++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 26 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index a858d8ef..e873eff0 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -22,17 +22,17 @@ import module namespace functx="http://www.functx.com"; : : @author Michelle Weidling :) -declare function fsort:main($tei as node()*, $log as xs:string) as element(tei:TEI) { - let $prepared := fsort:prepare($tei) - let $prepared := fsort:enhance-handshifts($prepared, $log) - let $fully-sorted := fsort:sort($prepared, $log) - let $integrations := fsort:sort-integrations($fully-sorted, $log) - let $highlighted := fsort:sort-highlighted-areas($integrations, $log) - let $id := $tei/@id - - let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $highlighted) - return $highlighted -}; + declare function fsort:main($tei as node()*, $log as xs:string) as element(tei:TEI) { + let $prepared := fsort:prepare($tei) + let $prepared := fsort:enhance-handshifts($prepared, $log) + let $fully-sorted := fsort:sort($prepared, $log) + let $integrations := fsort:sort-integrations($fully-sorted, $log) + let $transpositions := fsort:sort-transpositions($integrations, $log) + let $id := $tei/@id + + let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $transpositions) + return $transpositions + }; (:~ @@ -197,21 +197,21 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no : @param $node the current node : @return a copy of the current node with sorted descendants :) -declare function fsort:copy-node($node as node(), $flag as xs:string, $log as xs:string) as node() { - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - if($flag = "sort") then - fsort:sort($node/node(), $log) - else if($flag = "handshift") then - fsort:enhance-handshifts($node/node(), $log) - else if($flag = "sort-integrations") then - fsort:sort-integrations($node/node(), $log) - else if($flag = "sort-highlighted") then - fsort:sort-highlighted-areas($node/node(), $log) - else - error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) - } -}; + declare function fsort:copy-node($node as node(), $flag as xs:string, $log as xs:string) as node() { + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + if($flag = "sort") then + fsort:sort($node/node(), $log) + else if($flag = "handshift") then + fsort:enhance-handshifts($node/node(), $log) + else if($flag = "sort-integrations") then + fsort:sort-integrations($node/node(), $log) + else if($flag = "sort-transpositions") then + fsort:sort-transpositions($node/node(), $log) + else + error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) + } + }; @@ -475,3 +475,50 @@ as node()* { else fsort:copy-node($node, "sort-highlighted", $log) }; + + + +declare function fsort:sort-transpositions($nodes as node()*, $log as xs:string) as node()* { + for $node in $nodes return + + if(fsort:is-transposed($node) + and fsort:is-first-transposed($node)) then + let $transposed-order-ids := + for $ptr in $node/root()//tei:transpose/tei:ptr return + replace($ptr/@target, "#", "") => tokenize(" ") + + + return + element tei:seg { + attribute type {"transposed"}, + for $id in $transposed-order-ids return + let $corresp-node := $node/root()//*[@xml:id = $id] + return fsort:copy-node($corresp-node, "sort-transpositions", $log) + } + + else if(fsort:is-transposed($node) + or $node[self::tei:listTranspose]) then + () + + else if($node[self::text() or self::comment()]) then + $node + + else + fsort:copy-node($node, "sort-transpositions", $log) +}; + + +declare function fsort:is-transposed($node as node()*) as xs:boolean { + let $id := $node/@xml:id + let $transpositions := $node/root()//tei:transpose/tei:ptr + let $transpo-ids := for $ptr in $transpositions return + replace($ptr/@target, "#", "") => tokenize(" ") + + return $id = $transpo-ids +}; + + +declare function fsort:is-first-transposed($node as node()*) as xs:boolean { + let $first-transposed-id := replace($node/root()//tei:transpose/tei:ptr[1]/@target, "#", "") => tokenize(" ") + return $node/@xml:id = $first-transposed-id[1] +}; -- GitLab From 5dfb0ab46a9d1f938c14ce564f0a76ac6ea39fa6 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 23 Sep 2019 12:11:10 +0200 Subject: [PATCH 40/97] Implement multiphrases --- modules/fontane/edited-text/simple2xhtml.xqm | 28 ++++++++++----- modules/fontane/edited-text/sort.xqm | 36 +++++++++++++++++-- modules/fontane/edited-text/tei2teisimple.xqm | 12 ++++--- 3 files changed, 61 insertions(+), 15 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 04c6293c..3a0802d5 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -129,10 +129,15 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { (if($node/@type = "marked_off") then element xhtml:div { attribute class {"nb-editorial"}, - text{""} + text{""} } - else - (), + else if($node/@type = "multiphrase") then + element xhtml:div { + attribute class {"nb-editorial"}, + text{""} + } + else + (), element xhtml:div { if($node/@type = ("label", "additional", "marked_off")) then simple2xhtml:set-hs-info($node, "nb-" || $node/@type) @@ -143,12 +148,17 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { }, if($node/@type = "marked_off") then - element xhtml:div { - attribute class {"nb-editorial"}, - text{""} - } - else - () + element xhtml:div { + attribute class {"nb-editorial"}, + text{""} + } + else if($node/@type = "multiphrase") then + element xhtml:div { + attribute class {"nb-editorial"}, + text{""} + } + else + () ) case element(tei:expan) return diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index e873eff0..5c816193 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -28,10 +28,11 @@ import module namespace functx="http://www.functx.com"; let $fully-sorted := fsort:sort($prepared, $log) let $integrations := fsort:sort-integrations($fully-sorted, $log) let $transpositions := fsort:sort-transpositions($integrations, $log) + let $multiphrases := fsort:sort-multiphrases($integrations, $log) let $id := $tei/@id - let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $transpositions) - return $transpositions + let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $multiphrases) + return $multiphrases }; @@ -208,6 +209,8 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no fsort:sort-integrations($node/node(), $log) else if($flag = "sort-transpositions") then fsort:sort-transpositions($node/node(), $log) + else if($flag = "sort-multiphrases") then + fsort:sort-multiphrases($node/node(), $log) else error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) } @@ -522,3 +525,32 @@ declare function fsort:is-first-transposed($node as node()*) as xs:boolean { let $first-transposed-id := replace($node/root()//tei:transpose/tei:ptr[1]/@target, "#", "") => tokenize(" ") return $node/@xml:id = $first-transposed-id[1] }; + + +declare function fsort:sort-multiphrases($nodes as node()*, $log as xs:string) as node()* { + for $node in $nodes return + if($node[self::tei:addSpan[@type = "multiphrase" and @subtype = "extensive"]]) then + let $corresp-id := replace($node/@spanTo, "#", "") + let $corresp-node := $node/root()//*[@xml:id = $corresp-id] + + return + element tei:div { + attribute type {"multiphrase"}, + for $inbetween in $node/following-sibling::*[. << $corresp-node] return + fsort:copy-node($inbetween, "sort-multiphrases", $log), + $corresp-node + } + + else if($node[self::text() or self::comment()]) then + $node + + else + let $addSpan := $node/preceding-sibling::tei:addSpan[@type = "multiphrase" and @subtype = "extensive"] + let $anchor := $addSpan/root()//*[@xml:id = replace($addSpan/@spanTo, "#", "")] + + return + if($addSpan and $node/following::*[$anchor]) then + () + else + fsort:copy-node($node, "sort-multiphrases", $log) +}; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 1a134a20..455339c8 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -153,9 +153,13 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) else if($node/@place = "above" - and $node/preceding::node()[1][normalize-space(.) = ""]) then + and ($node/preceding::node()[1][normalize-space(.) = ""] or $node/ancestor::tei:seg[@type = "transposed"])) then (text{" "}, - fontaneSimple:transform($node/node(), $uri, $log)) + fontaneSimple:transform($node/node(), $uri, $log), + if($node/ancestor::tei:seg[@type = "transposed"]) then + text{" "} + else + ()) else if($node[@place = "superimposed"]) then fontaneSimple:preserve-whitespace($node, $uri, $log) @@ -344,7 +348,7 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = ("integration", "editorial-label", "col", "marked_off")) then + else if($node/@type = ("integration", "editorial-label", "col", "marked_off", "transposed")) then element tei:seg { $node/@*, fontaneSimple:transform($node/node(), $uri, $log) @@ -573,7 +577,7 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@type = ("dialogue", "edited_text")) then + else if($node/@type = ("dialogue", "edited_text", "multiphrase")) then element tei:div { $node/@*, fontaneSimple:transform($node/node(), $uri, $log) -- GitLab From 91a2bb7315629b47061b9ece599458b4fc5bb88b Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 23 Sep 2019 17:05:44 +0200 Subject: [PATCH 41/97] Implement footnotes and special characters --- modules/fontane/edited-text/simple2xhtml.xqm | 40 ++++++++++++++++--- modules/fontane/edited-text/tei2teisimple.xqm | 6 +-- .../fontane/edited-text/teisimplehelpers.xqm | 3 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 3a0802d5..a9fded05 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -58,6 +58,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { element xhtml:span { simple2xhtml:set-hs-info($node, "text"), replace($node, " ,", ",") + => replace("\?@\?", " ") + => replace("\?@@\?", "〃") => replace(" \?", "?") => replace(" \.", ".") => replace(" ;", ";") @@ -70,10 +72,18 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } case element(tei:body) return - element xhtml:div { - simple2xhtml:set-hs-info($node, ()), - simple2xhtml:recursion($node/node()) - } + ( + element xhtml:div { + simple2xhtml:set-hs-info($node, ()), + simple2xhtml:recursion($node/node()) + }, + for $note in $node/root()//tei:note[@type = "authorial" and @subtype ="footnote"] return + element xhtml:div { + attribute id {$note/../@xml:id}, + attribute class {"nb-footnote"}, + simple2xhtml:recursion($note/node()) + } + ) case element(tei:abbr) return (text{" "}, @@ -197,6 +207,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:lb) return if ($node/@type="edited_text") then element xhtml:br {} + else if ($node/@type="keepIndent") then + element xhtml:div { + attribute class {"nb-keepIndent"} + } else () @@ -529,12 +543,13 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () case element(tei:note) return - if($node/@type = ("editorial", "authorial")) then + if($node/@type = ("editorial", "authorial") + and not($node/@subtype = "footnote")) then element xhtml:span { attribute class {$node/@type || "-note"}, simple2xhtml:recursion($node/node()) } - else if($node/@subtype = ("footnote", "revision")) then + else if($node/@subtype = ("revision")) then element xhtml:div { attribute class {"nb-" || $node/@subtype}, simple2xhtml:recursion($node/node()) @@ -644,6 +659,19 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else () + case element(tei:ref) return + if($node/tei:ab[@type = "footnote-mark"]) then + let $target-id := replace($node/@target, "#", "") + let $target := $node/root()//*[@xml:id = $target-id] + + return + element xhtml:a { + attribute href {$node/@target}, + simple2xhtml:recursion($node/tei:ab) + } + else + simple2xhtml:recursion($node/node()) + default return simple2xhtml:recursion($node/node()) }; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 455339c8..9c5ee61c 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -143,12 +143,12 @@ $log as xs:string) as node()* { else if($node/@cause = "unclear") then () - else if($node[replace($node/@copyOf, "#", "") = $node/ancestor::tei:TEI//tei:seg/@xml:id]) then - fontaneSimple:mark-intervention($node, $uri, $log) - else if($node/@cause ="catchword") then () + else if($node[replace($node/@copyOf, "#", "") = $node/ancestor::tei:TEI//tei:seg/@xml:id]) then + fontaneSimple:mark-intervention($node, $uri, $log) + else if($node/@rend ="|") then fontaneSimple:transform($node/node(), $uri, $log) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 3ab41919..85f59d58 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -103,7 +103,8 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? { else $cleared-round-s let $escaped-big-space := text{replace($cleared-big-space, " ", "?@?")} - let $cleared-Tironian := replace($cleared-big-space, "⁊c.", "etc.") + let $escaped-dito := text{replace($escaped-big-space, "〃", "?@@?")} + let $cleared-Tironian := replace($escaped-dito, "⁊c.", "etc.") return (: in cases where a given $node only consists of a hyphen we don't return a text node because it's unnecessary and leads to problems -- GitLab From 9113529b5216037b99d03008f1e7a0e0c236a147 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 24 Sep 2019 14:35:10 +0200 Subject: [PATCH 42/97] Declutter --- modules/fontane/edited-text/prepcom.xqm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/fontane/edited-text/prepcom.xqm b/modules/fontane/edited-text/prepcom.xqm index 0cb70fd9..ed5894d3 100644 --- a/modules/fontane/edited-text/prepcom.xqm +++ b/modules/fontane/edited-text/prepcom.xqm @@ -12,13 +12,9 @@ xquery version "3.1"; module namespace prepCom="http://fontane-nb.dariah.eu/prepCom"; declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace xi="http://www.w3.org/2001/XInclude"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; -import module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple" at "tei2teisimple.xqm"; -import module namespace functx = "http://www.functx.com"; -import module namespace simple2xhtml="http://fontane-nb.dariah.eu/simple2xhtml" at "simple2xhtml.xqm"; -import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at "tidysimple.xqm"; + declare variable $prepCom:literature := map:merge(for $entry in doc("/db/sade-projects/textgrid/data/xml/data/25547.xml")//tei:bibl -- GitLab From 9e4aa0892095257e4faccfe0795da9502941aa7c Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 24 Sep 2019 14:59:50 +0200 Subject: [PATCH 43/97] Implement abbreviations --- modules/fontane/edited-text/simple2xhtml.xqm | 58 ++++++++++++++++++- modules/fontane/edited-text/tei2teisimple.xqm | 24 ++++++-- modules/fontane/edited-text/tidysimple.xqm | 3 + 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index a9fded05..f27e19bb 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -86,7 +86,11 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ) case element(tei:abbr) return - (text{" "}, + ( + if($node/@prev) then + () + else + text{" "}, element xhtml:span { simple2xhtml:set-hs-info($node, "abbr"), simple2xhtml:recursion($node/node()) @@ -307,6 +311,9 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/preceding-sibling::*[1][self::tei:rs[concat('#', @xml:id) = $node/following-sibling::*[2][self::tei:rs]/@prev]]) then () + else if($node/preceding-sibling::*[1][self::tei:abbr[@next]]) then + () + else text{" "} @@ -404,7 +411,30 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:recursion($node/node()) case element(tei:figure) return - if(not($node/ancestor::tei:ab/preceding-sibling::*[1][descendant::tei:figure[@type = "double"]])) then + if($node/ancestor::tei:div/@type = "genealogy") then + let $coordinates := tokenize( $node/ancestor::tei:div[1]/@points, ' ' ) + return + ( + {$node/@xml:id ! attribute id { string(.) }, + for $pair in 1 to (count($coordinates) - 1) + let $x1 := tokenize($coordinates[$pair], ',')[1] + let $y1 := tokenize($coordinates[$pair], ',')[2] + let $x2 := tokenize($coordinates[$pair + 1], ',')[1] + let $y2 := tokenize($coordinates[$pair + 1], ',')[2] + return + + } + , + element xhtml:div { + attribute class {'hrHover'}, + tokenize($node//tei:figDesc/tei:ref/text(), ' ')[2] => replace(";", "") + } + ) + + else if(not($node/ancestor::tei:ab/preceding-sibling::*[1][descendant::tei:figure[@type = "double"]])) then let $captions-before := $node/preceding-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] let $captions-after := @@ -453,6 +483,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { simple2xhtml:make-img-captions($captions-after, "left-aligned") else ()) + (: right parts of sketches on double pages are processed when processing the left part :) else () @@ -672,6 +703,29 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else simple2xhtml:recursion($node/node()) + case element(tei:choice) return + if($node/tei:expan) then + element xhtml:span { + attribute class {"choice"}, + element xhtml:div { + attribute class {"expan italic"}, + simple2xhtml:recursion($node/tei:expan/node()) + }, + simple2xhtml:recursion($node/tei:abbr) + } + else + simple2xhtml:recursion($node/node()) + + case element(tei:abbr) return + element xhtml:span { + attribute id {$node/@xml:id}, + attribute class {"abbr"}, + simple2xhtml:recursion($node/node()) + } + + case element(tei:expan) return + () + default return simple2xhtml:recursion($node/node()) }; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 9c5ee61c..94d537a5 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -13,10 +13,7 @@ xquery version "3.1"; module namespace fontaneSimple="http://fontane-nb.dariah.eu/teisimple"; -declare namespace svg="http://www.w3.org/2000/svg"; declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare namespace test="http://exist-db.org/xquery/xqsuite"; -declare namespace xlink="http://www.w3.org/1999/xlink"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; import module namespace functx="http://www.functx.com"; @@ -97,9 +94,14 @@ $log as xs:string) as node()* { else if($node/ancestor::tei:seg[@type = "editorial-label"]) then text{" "} - else if($node[@break = "no"]) then + else if($node[@break = "no"] + and not($node/preceding-sibling::tei:line[1]/child::*[last()][self::tei:choice])) then fontaneSimple:mark-intervention($node, $uri, $log) + else if($node[@break = "no"] + and $node/preceding-sibling::tei:line[1]/child::*[last()][self::tei:choice]) then + () + else fontaneSimple:copy-element($node, $uri, $log) @@ -198,11 +200,13 @@ $log as xs:string) as node()* { or matches($node/@rendition, "roman")) then fontaneSimple:make-seg-with-rendition($node, $uri, $log) - else if($node/following::*[1][self::tei:lb[@break = "no"]]) then + else if($node/following::*[1][self::tei:lb[@break = "no"]] + and not($node/child::*[last()][self::tei:choice])) then (simpleHelpers:start-line($node), simpleHelpers:trim-last-char($node)) - else if ($node/preceding::*[1][self::tei:lb[@break = "no"]]) then + else if($node/preceding::*[1][self::tei:lb[@break = "no"]] + and not($node/child::*[1][self::tei:choice])) then (simpleHelpers:start-line($node), simpleHelpers:trim-first-char($node)) @@ -487,6 +491,13 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } + else if($node/@points and $node//tei:figure) then + element tei:div { + $node/@*, + attribute type {"genealogy"}, + fontaneSimple:transform($node/node(), $uri, $log) + } + else if(matches($node/@rend, "border-bottom-style:brace")) then (fontaneSimple:transform($node/node(), $uri, $log), element tei:ab { @@ -703,6 +714,7 @@ $log as xs:string) as node()* { attribute type {"difference"} } + (: 3.7.13.2 Nicht ermittelte Skizzen :) else if(not($node/@xml:id)) then () diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 58a0f318..9a8e3ff0 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -505,6 +505,9 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { case element(tei:table) return tidySimple:summarize-entries($node) + case element(tei:note) return + tidySimple:summarize-entries($node) + default return if($node/descendant::*[self::tei:milestone[@unit = "line"] or self::tei:rs or self::tei:list or self::tei:item or self::tei:seg or self::tei:table][@prev or @next]) then -- GitLab From be25309ad9a4f7e65a4ff2c9783e0325401e0175 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Fri, 27 Sep 2019 14:01:41 +0200 Subject: [PATCH 44/97] Tidy up, add docs --- modules/fontane/edited-text/simple2xhtml.xqm | 144 +++++++++++++------ modules/fontane/edited-text/sort.xqm | 62 ++++---- modules/fontane/edited-text/tidysimple.xqm | 58 +++++--- 3 files changed, 174 insertions(+), 90 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index f27e19bb..8682fd20 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -18,24 +18,26 @@ import module namespace config="http://textgrid.de/ns/SADE/config" at "../../con declare function simple2xhtml:main($nodes as node()*, $uri as xs:string) { let $xhtml := element xhtml:div {simple2xhtml:recursion($nodes//tei:text)} let $tidy := element xhtml:div {simple2xhtml:tidy($xhtml)} - let $store := xmldb:store($config:data-root || "/print/xhtml/", $uri || ".html", $tidy) return - $tidy + xmldb:store($config:data-root || "/print/xhtml/", $uri || ".html", $tidy) }; (:~ : Tidy up all that messy white spaces. - : @TODO further optimization of tei2simple :) -declare function simple2xhtml:fix-whitespaces($nodes as node()*) as node()* { - let $string := - serialize($nodes) -(: => replace("[\t\n]", ""):) -(: => replace("[\s]+", " "):) -(: => replace(" ,", ","):) -(: => replace(" \.", "."):) - - return $string +declare function simple2xhtml:fix-whitespaces($node as xs:string) as xs:string { + replace($node, " ,", ",") + => replace("\?@\?", " ") + => replace("\?@@\?", "〃") + => replace(" \?", "?") + => replace(" \.", ".") + => replace(" ;", ";") + => replace("@@", " ") + => replace("@P", "") + => replace("@", "") + => replace("  ", " ") + => replace(":", ": ") + => replace(" “", "“") }; @@ -57,18 +59,11 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else element xhtml:span { simple2xhtml:set-hs-info($node, "text"), - replace($node, " ,", ",") - => replace("\?@\?", " ") - => replace("\?@@\?", "〃") - => replace(" \?", "?") - => replace(" \.", ".") - => replace(" ;", ";") - => replace("@@", " ") - => replace("@P", "") - => replace("@", "") - => replace("  ", " ") - => replace(":", ": ") - => replace(" “", "“") + if($node/preceding-sibling::*[1][self::tei:milestone[@rendition = "indent"]]) then + attribute style {"margin-left: 20px;"} + else + (), + simple2xhtml:fix-whitespaces($node) } case element(tei:body) return @@ -153,7 +148,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else (), element xhtml:div { - if($node/@type = ("label", "additional", "marked_off")) then + if($node/@type = ("label", "additional", "marked_off", "indent")) then simple2xhtml:set-hs-info($node, "nb-" || $node/@type) else @@ -293,7 +288,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:milestone) return if($node/@unit = "line" and ($node/ancestor::tei:list and not($node/ancestor::tei:item) - or $node/ancestor::tei:seg[@type = "said"] + or $node/ancestor::tei:seg[@type = "said"][not(preceding-sibling::*[1][self::*[@type = "said"]] or preceding-sibling::*[1]//*[last()][self::*[@type = "said"]])] or $node/ancestor::tei:div[@type = "edited_text"])) then element xhtml:br {} @@ -353,14 +348,20 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ) case element(tei:ab) return - if($node/@type = "sketch"") then" + if($node/@type = "sketch" and $node/descendant::tei:figure) then - element xhtml:table { - attribute class {"nb-sketch"}, - element xhtml:tr { - simple2xhtml:recursion($node/node()) + ( + if($node//tei:ptr[@type = "editorial-commentary"]) then + simple2xhtml:recursion($node//tei:ptr[@type = "editorial-commentary"]) + else + (), + element xhtml:table { + attribute class {"nb-sketch"}, + element xhtml:tr { + simple2xhtml:recursion($node/node()) + } } - } + ) else if($node/@type = ("caret")) then () @@ -412,9 +413,9 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:figure) return if($node/ancestor::tei:div/@type = "genealogy") then - let $coordinates := tokenize( $node/ancestor::tei:div[1]/@points, ' ' ) + let $coordinates := tokenize( $node/ancestor::tei:div[1]/@points, " ") return - ( @@ -425,7 +426,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { let $x2 := tokenize($coordinates[$pair + 1], ',')[1] let $y2 := tokenize($coordinates[$pair + 1], ',')[2] return - + } , element xhtml:div { @@ -548,11 +549,17 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } else - element xhtml:span { - simple2xhtml:set-hs-info($node, "nb-seg"), - attribute style {$node/@rendition}, - simple2xhtml:recursion($node/node()) - } + ( + element xhtml:span { + simple2xhtml:set-hs-info($node, "nb-seg"), + attribute style {$node/@rendition}, + simple2xhtml:recursion($node/node()) + }, + if($node/ancestor::*[@type ="said"]) then + element xhtml:br {} + else + () + ) case element(tei:unclear) return element xhtml:span { @@ -574,12 +581,14 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { () case element(tei:note) return - if($node/@type = ("editorial", "authorial") + if($node/@type = ("editorial") and not($node/@subtype = "footnote")) then element xhtml:span { attribute class {$node/@type || "-note"}, simple2xhtml:recursion($node/node()) } + else if($node/@type = "authorial") then + simple2xhtml:make-modal($node) else if($node/@subtype = ("revision")) then element xhtml:div { attribute class {"nb-" || $node/@subtype}, @@ -726,6 +735,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:expan) return () + case element(tei:ptr) return + if($node[@type = "editorial-commentary"]) then + simple2xhtml:make-modal($node) + else + () + default return simple2xhtml:recursion($node/node()) }; @@ -988,6 +1003,7 @@ $target as node()*) { } }; +(:~ A final tidying of broken white spaces. :) declare function simple2xhtml:tidy($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -1008,3 +1024,49 @@ declare function simple2xhtml:tidy($nodes as node()*) as node()* { simple2xhtml:tidy($node/node()) } }; + + +(:~ Creates an icon and a modal window for an editorial or authorial comment. + : + : @author Michelle Weidling + : @param $node a tei:ptr or tei:note[@type = 'authorial'] + : @return an icon as xhtml:i and a modal window as xhtml:div + :) +declare function simple2xhtml:make-modal($node as node()) as element(*)+ { + let $content := + if($node/ancestor::tei:ab[@type = "sketch"]) then + $node/following-sibling::tei:figDesc/tei:ref//text()[not(ancestor::tei:index)] + => string-join(" ") + => simple2xhtml:fix-whitespaces() + + else if($node[self::tei:note]) then + simple2xhtml:recursion($node/node()) + + else + () + let $id := util:hash(generate-id($node), "md5") + let $target := "#" || $id + return + ( + , + + ) +}; diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 5c816193..16162947 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -449,38 +449,15 @@ declare function fsort:sort-integrations($nodes as node()*, $log as xs:string) a }; -declare function fsort:sort-highlighted-areas($nodes as node()*, $log as xs:string) -as node()* { - for $node in $nodes return - typeswitch ($node) - case text() return - $node - - case comment() return - $node - - case element(tei:mod) return - if($node/@type = "highlighted" and matches($node/@hand, "Fontane")) then - element tei:seg { - attribute type {"highlighted-area"}, - $node/following::*[. << following::tei:anchor["#" || @xml:id = $node/@spanTo]] - } - else - fsort:copy-node($node, "sort-highlighted", $log) - default return - if($node/preceding::tei:mod[@type = "highlighted"][1][matches(@hand, "Fontane")]) then - let $id := replace($node/preceding::tei:mod[@type = "highlighted"][1][matches(@hand, "Fontane")]/@spanTo, "#", "") - return - if($node/following::tei:anchor[@xml:id = $id]) then - () - else - fsort:copy-node($node, "sort-highlighted", $log) - else - fsort:copy-node($node, "sort-highlighted", $log) -}; - - - +(:~ In some cases we have text that is transposed, i.e. two or more areas of + : text that are switched. The correct order of the texts is denoted in a tei:listTranspose. + : This function serves restore the intended order by setting the sequence of texts + : of tei:listTranspose when the first transposed element is met. + : + : @author Michelle Weidling + : @param $nodes the nodes to be processed + : @param path to log file + : @return the processed nodes. transpositions are put in the right order, the rest is kept as is :) declare function fsort:sort-transpositions($nodes as node()*, $log as xs:string) as node()* { for $node in $nodes return @@ -511,6 +488,12 @@ declare function fsort:sort-transpositions($nodes as node()*, $log as xs:string) }; +(:~ Checks if a node with an xml:id is transposed or not. + : + : @author Michelle Weidling + : @param $node A node with an xml:id + : @return true() when the node's xml:id is mentioned in tei:listTranspose, false() otherwise + :) declare function fsort:is-transposed($node as node()*) as xs:boolean { let $id := $node/@xml:id let $transpositions := $node/root()//tei:transpose/tei:ptr @@ -521,12 +504,27 @@ declare function fsort:is-transposed($node as node()*) as xs:boolean { }; +(:~ Checks if a node with an xml:id is the first transposed element in a + : tei:listTranspose. + : + : @author Michelle Weidling + : @param $node A node with an xml:id + : @return true() when the node's xml:id is the first transposed element, false() otherwise + :) declare function fsort:is-first-transposed($node as node()*) as xs:boolean { let $first-transposed-id := replace($node/root()//tei:transpose/tei:ptr[1]/@target, "#", "") => tokenize(" ") return $node/@xml:id = $first-transposed-id[1] }; +(:~ In some cases we have text two or more longer variations of a text passage, + : e.g. in a draft for a piece of literature. These passages should be marked as + : different layers of text and have to be put into the right order. + : + : @author Michelle Weidling + : @param $nodes the nodes to be processed + : @param path to log file + : @return the processed nodes. transpositions are put in the right order, the rest is kept as is :) declare function fsort:sort-multiphrases($nodes as node()*, $log as xs:string) as node()* { for $node in $nodes return if($node[self::tei:addSpan[@type = "multiphrase" and @subtype = "extensive"]]) then diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 9a8e3ff0..f70f7ed4 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -36,6 +36,7 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { => tidySimple:split-headings() => tidySimple:summarize() => tidySimple:summarize-headings() + => tidySimple:summarize-notes() => tidySimple:sort-double-imgs() let $header := tidySimple:get-Fontanes-sources($tei//tei:teiHeader[parent::tei:TEI]) @@ -277,6 +278,8 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string) tidySimple:summarize($node/node()) else if($flag = "summarize-headings") then tidySimple:summarize-headings($node/node()) + else if($flag = "summarize-notes") then + tidySimple:summarize-notes($node/node()) else if($flag = "ref") then tidySimple:get-references-in-abstract($node/node()) else if($flag = "double-imgs") then @@ -417,22 +420,6 @@ declare function tidySimple:split-headings($nodes as node()*) as node()* { } }; - -declare function tidySimple:get-next-content($node as node()*, $content as node()*) -as node()* { - if($node/@next) then - let $next-hi-id := substring-after($node/@next, "#") - let $next-node := $node/following-sibling::*[@xml:id = $next-hi-id] - let $next-content := $next-node//text()[not(ancestor::tei:index)] - let $break := if($node/@break = "true") then text{" "} else () - let $content := ($content, $break, $next-content) - - return - tidySimple:get-next-content($next-node, $content) - else - $content -}; - declare function tidySimple:get-Fontanes-sources($header as node()*) { for $node in $header return typeswitch ($node) @@ -510,7 +497,12 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { default return - if($node/descendant::*[self::tei:milestone[@unit = "line"] or self::tei:rs or self::tei:list or self::tei:item or self::tei:seg or self::tei:table][@prev or @next]) then + if($node/descendant::*[self::tei:milestone[@unit = "line"] + or self::tei:rs + or self::tei:list + or self::tei:item + or self::tei:seg + or self::tei:table][@prev or @next]) then tidySimple:copy-element($node, "summarize") else $node @@ -672,3 +664,35 @@ declare function tidySimple:summarize-headings($nodes as node()*) as node()* { default return tidySimple:copy-element($node, "summarize-headings") }; + + +(:~ A function for summarizing tei:note, especially for authorial notes :) +declare function tidySimple:summarize-notes($nodes as node()*) as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + $node + + case comment() return + $node + + case element(tei:note) return + if($node/@next) then + let $next-id := tidySimple:get-id($node/@next) + let $corresp-node := tidySimple:find-corresp-node($node, "next") + + return + element tei:note { + $node/(@* except @next), + $node/node(), + $corresp-node/node() + } + else if($node/@prev) then + () + else + tidySimple:copy-element($node, "summarize-notes") + + default return + tidySimple:copy-element($node, "summarize-notes") +}; -- GitLab From 3c59f8c04f701bcd8abb915f1a5b0d83fa9aba10 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 7 Oct 2019 16:32:40 +0200 Subject: [PATCH 45/97] Improve white space handling, summarize tei:hi --- modules/fontane/edited-text/simple2xhtml.xqm | 13 +-- modules/fontane/edited-text/tidysimple.xqm | 109 ++++++++++++++++++- 2 files changed, 109 insertions(+), 13 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 8682fd20..e4526f8e 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -37,7 +37,7 @@ declare function simple2xhtml:fix-whitespaces($node as xs:string) as xs:string { => replace("@", "") => replace("  ", " ") => replace(":", ": ") - => replace(" “", "“") + => replace("\s+“", "“") }; @@ -197,11 +197,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } else - (text{" "}, element xhtml:span { simple2xhtml:set-hs-info($node, "nb-underline"), simple2xhtml:recursion($node/node()) - }) + } case element(tei:lb) return if ($node/@type="edited_text") then @@ -287,8 +286,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { case element(tei:milestone) return if($node/@unit = "line" - and ($node/ancestor::tei:list and not($node/ancestor::tei:item) - or $node/ancestor::tei:seg[@type = "said"][not(preceding-sibling::*[1][self::*[@type = "said"]] or preceding-sibling::*[1]//*[last()][self::*[@type = "said"]])] + and ($node/ancestor::tei:seg[@type = "said"][not(preceding-sibling::*[1][self::*[@type = "said"]] or preceding-sibling::*[1]//*[last()][self::*[@type = "said"]])] or $node/ancestor::tei:div[@type = "edited_text"])) then element xhtml:br {} @@ -363,10 +361,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } ) - else if($node/@type = ("caret")) then - () - - else if($node/@type = "footnote-mark") then + else if($node/@type = ("footnote-mark", "caret")) then element xhtml:seg { attribute class {"nb-" || $node/@type}, simple2xhtml:recursion($node/node()) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index f70f7ed4..464ac013 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -37,7 +37,9 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { => tidySimple:summarize() => tidySimple:summarize-headings() => tidySimple:summarize-notes() + => tidySimple:summarize-hi() => tidySimple:sort-double-imgs() + => tidySimple:tidy() let $header := tidySimple:get-Fontanes-sources($tei//tei:teiHeader[parent::tei:TEI]) => tidySimple:get-references-in-abstract() @@ -280,10 +282,14 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string) tidySimple:summarize-headings($node/node()) else if($flag = "summarize-notes") then tidySimple:summarize-notes($node/node()) + else if($flag = "summarize-hi") then + tidySimple:summarize-hi($node/node()) else if($flag = "ref") then tidySimple:get-references-in-abstract($node/node()) else if($flag = "double-imgs") then tidySimple:sort-double-imgs($node/node()) + else if($flag = "tidy") then + tidySimple:tidy($node/node()) else text{"!!!Kopieren des Elements fehlgeschlagen!!!"} } @@ -529,12 +535,20 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { (: entry point of virtual aggregation:) if($node/@next and not($node/@prev)) then let $next-node := tidySimple:find-corresp-node($node, "next") - let $nodes-inbetween := $node/following::node()[. << $next-node] + let $nodes-inbetween := $node/following-sibling::node()[. << $next-node] + let $is-next-node-nested := + if($nodes-inbetween/descendant::* = $next-node) then + true() + else + () return if(count($next-node) = 1) then (tidySimple:summarize($node/node()), $nodes-inbetween, - tidySimple:apply-all-nexts($next-node)) + if($is-next-node-nested) then + () + else + tidySimple:apply-all-nexts($next-node)) else tidySimple:summarize($node/node()) @@ -545,17 +559,44 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { (: element in the middle of a virtual aggregation:) else let $next-node := tidySimple:find-corresp-node($node, "next") - let $nodes-inbetween := $node/following::node()[. << $next-node] + let $nodes-inbetween := $node/following-sibling::node()[. << $next-node] + let $is-next-node-nested := + if($nodes-inbetween/descendant::* = $next-node) then + true() + else + () return if(count($next-node) = 1) then (tidySimple:summarize($node/node()), $nodes-inbetween, - tidySimple:apply-all-nexts($next-node)) + if($is-next-node-nested) then + () + else + tidySimple:apply-all-nexts($next-node)) else tidySimple:summarize($node/node()) }; +declare function tidySimple:exclude-nested-hi($nodes as node()*, $hi-to-exclude as element(tei:hi)) as node()* { + for $node in $nodes return + typeswitch ($node) + case text() return + $node + + case comment() return + $node + + default return + if($node = $hi-to-exclude) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:exclude-nested-hi($node/node(), $hi-to-exclude) + } +}; + declare function tidySimple:find-corresp-node($node as node(), $flag as xs:string) { let $target-id := if($flag = "next") then @@ -696,3 +737,63 @@ declare function tidySimple:summarize-notes($nodes as node()*) as node()* { default return tidySimple:copy-element($node, "summarize-notes") }; + + +(:~ A function for summarizing tei:hi :) +declare function tidySimple:summarize-hi($nodes as node()*) as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + $node + + case comment() return + $node + + case element(tei:hi) return + (: first element of virtual aggregation :) + if($node/@next and not($node/@prev)) then + element tei:hi { + $node/(@* except @next), + tidySimple:apply-all-nexts($node) + } + (: middle or last element o virutal aggregation:) + else if($node/@prev) then + () + (: not part of virtual aggregation at all :) + else + tidySimple:copy-element($node, "summarize-hi") + + default return + tidySimple:copy-element($node, "summarize-hi") +}; + + +declare function tidySimple:tidy($nodes as node()*) as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + if(normalize-space($node) = "") then + if($node/preceding::*[1][self::tei:milestone[@unit = "line"]] + and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then + () + else + $node + else + $node + + case element(tei:milestone) return + if($node[@unit = "line"]) then + if(($node/following::node()[1][self::tei:milestone[@unit = "line"]] + or normalize-space($node/following::node()[1]) = "") + and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then + () + else + $node + else + $node + + default return + tidySimple:copy-element($node, "tidy") +}; -- GitLab From 226fed287c5f3dc85a64b5a7a828474238032eed Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 8 Oct 2019 08:38:02 +0200 Subject: [PATCH 46/97] Remove dead code --- modules/fontane/edited-text/sort.xqm | 56 ---------------------------- 1 file changed, 56 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 16162947..26522d22 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -236,62 +236,6 @@ declare function fsort:get-id($target as xs:string) as xs:string { }; -(:~ - : tei:rs oftentimes has one or several element(s) as descendant(s) which can be in - : the middle or end of a virtual aggregation. These have already been handled by - : sort:apply-all-nexts and should therefore not be considered. - : - : @author Michelle Weidling - : @param $node the current tei:rs - : @return tei:rs - :) -declare function fsort:exclude-copied($node as element(tei:rs)) as -element(tei:rs)? { - if(fsort:has-only-copied-children($node)) then - () - else - let $rs-children := $node/node() - let $processed-children := - for $child in $rs-children return - if($child/@next - and not(matches($child/@style, "underline"))) then - fsort:apply-all-nexts($child, $log) - else - $child - - return - if(count($processed-children) gt 0) then - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - $processed-children - } - else - () -}; - -(:~ - : tei:rs oftentimes has one or several element(s) as descendant(s) which can be part - : of a virtual aggregation. If this applies to all children of tei:rs, all of them - : have been handled by fsort:apply-all-nexts, thus leaving the tei:rs empty. - : - : In these cases we need an indicator if we can savely drop a tei:rs. - : - : @author Michelle Weidling - : @param $node the current tei:rs - : @return xs:boolean - : :) -declare function fsort:has-only-copied-children($node as element()) as -xs:boolean { - let $are-copied := - for $desc in $node//node() return - if($desc[@prev]) then - true() - else - false() - return - not($are-copied = false()) -}; - declare function fsort:add-log-entry($log-file as xs:string, $message as xs:string) as empty-sequence() { -- GitLab From 92f8d7f2784b92596f43b854adf9f6986e85f20a Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 8 Oct 2019 14:27:33 +0200 Subject: [PATCH 47/97] Further work on white spaces, additions and commentary --- modules/fontane/edited-text/simple2xhtml.xqm | 69 +++++++++++++++----- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index e4526f8e..a2d155f0 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -26,18 +26,31 @@ declare function simple2xhtml:main($nodes as node()*, $uri as xs:string) { : Tidy up all that messy white spaces. :) declare function simple2xhtml:fix-whitespaces($node as xs:string) as xs:string { - replace($node, " ,", ",") - => replace("\?@\?", " ") - => replace("\?@@\?", "〃") - => replace(" \?", "?") - => replace(" \.", ".") - => replace(" ;", ";") - => replace("@@", " ") - => replace("@P", "") - => replace("@", "") - => replace("  ", " ") - => replace(":", ": ") - => replace("\s+“", "“") + let $general := + replace($node, " ,", ",") + => replace("\?@\?", " ") + => replace("\?@@\?", "〃") + => replace(" \?", "?") + => replace(" \.", ".") + => replace(" ;", ";") + => replace("@@", " ") + => replace("  ", " ") + => replace(":", ": ") + => replace("\s+“", "“") +(: let $general :=:) +(: if(normalize-space($node) = "":) +(: and matches(substring($node/following::text()[1], 1, 1), "[,\.“\-\)]")) then:) +(: ():) +(: else:) +(: $node:) + let $hyphen := + if(matches($general, "@P[A-Z]")) then + replace($general, "@P", "-") + => replace("@", "") + else + replace($general, "@P", "") + => replace("@", "") + return $hyphen }; @@ -293,7 +306,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/@unit = "line") then let $next-char := substring($node/following::text()[1], 1, 1) return - if(matches($next-char, "[\.\)\?,;!]") + if((matches($next-char, "[\.\)\?,;!]") or $next-char = "“") and not(ends-with($node/preceding::text()[1], "@P"))) then () @@ -361,12 +374,15 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { } ) - else if($node/@type = ("footnote-mark", "caret")) then + else if($node/@type = "footnote-mark") then element xhtml:seg { attribute class {"nb-" || $node/@type}, simple2xhtml:recursion($node/node()) } + else if($node/@type = "caret") then + () + else if($node/@type = "verse_marker") then element xhtml:seg { attribute class {"nb-" || $node/@type}, @@ -550,6 +566,15 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { attribute style {$node/@rendition}, simple2xhtml:recursion($node/node()) }, + if(matches($node/@rendition, "letter\-spacing") + and not(ends-with($node, "-"))) then + let $next-char := substring($node/following::text()[1], 1, 1) + return if(matches($next-char, "\.,\)")) then + () + else + text{" "} + else + (), if($node/ancestor::*[@type ="said"]) then element xhtml:br {} else @@ -715,7 +740,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { attribute class {"expan italic"}, simple2xhtml:recursion($node/tei:expan/node()) }, - simple2xhtml:recursion($node/tei:abbr) + simple2xhtml:recursion($node/tei:abbr), + let $next-char := substring($node/following::text()[1], 1, 1) + return if(matches($next-char, "\.,\)")) then + () + else + text{" "} } else simple2xhtml:recursion($node/node()) @@ -1037,11 +1067,18 @@ declare function simple2xhtml:make-modal($node as node()) as element(*)+ { else if($node[self::tei:note]) then simple2xhtml:recursion($node/node()) + else if($node[self::tei:ptr]) then + let $corresp-node := $node/root()//*[@target = "#" || $node/@reference] + return + simple2xhtml:recursion($corresp-node/node()) + else () + let $id := util:hash(generate-id($node), "md5") let $target := "#" || $id return + if($content) then ( , ) + else + () }; -- GitLab From b6be8d634fa949727f66a8ec97611e99bf8ba081 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 8 Oct 2019 14:28:48 +0200 Subject: [PATCH 48/97] Fix marginal additions by Fontane --- modules/fontane/edited-text/sort.xqm | 69 ++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 26522d22..4010d548 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -25,6 +25,7 @@ import module namespace functx="http://www.functx.com"; declare function fsort:main($tei as node()*, $log as xs:string) as element(tei:TEI) { let $prepared := fsort:prepare($tei) let $prepared := fsort:enhance-handshifts($prepared, $log) + let $prepared := fsort:sort-certain-anchors($prepared, $log) let $fully-sorted := fsort:sort($prepared, $log) let $integrations := fsort:sort-integrations($fully-sorted, $log) let $transpositions := fsort:sort-transpositions($integrations, $log) @@ -33,6 +34,8 @@ import module namespace functx="http://www.functx.com"; let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $multiphrases) return $multiphrases +(: let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $prepared):) +(: return $prepared:) }; @@ -95,8 +98,11 @@ declare function fsort:default-return($node as node(), $log as xs:string) as nod fsort:apply-all-nexts($node, $log) (: since all parts of the virtual aggregation are handled by fsort:apply-all-nexts - we can ignore the ones that have a @prev :) - else if($node[@prev]) then + we can ignore the ones that have a @prev. + this doesn't hold for the ones with a @anchor, since they are the first real + element of a virtual aggregation that has been started by an anchor when we + have an addition in a page's margin (3.21.13.3) :) + else if($node[@prev] and not($node/@anchor = "true")) then () (: we distinguish this case and the one below to improve performance :) @@ -199,20 +205,22 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no : @return a copy of the current node with sorted descendants :) declare function fsort:copy-node($node as node(), $flag as xs:string, $log as xs:string) as node() { - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - if($flag = "sort") then - fsort:sort($node/node(), $log) - else if($flag = "handshift") then - fsort:enhance-handshifts($node/node(), $log) - else if($flag = "sort-integrations") then - fsort:sort-integrations($node/node(), $log) - else if($flag = "sort-transpositions") then - fsort:sort-transpositions($node/node(), $log) + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + if($flag = "sort") then + fsort:sort($node/node(), $log) + else if($flag = "handshift") then + fsort:enhance-handshifts($node/node(), $log) + else if($flag = "sort-integrations") then + fsort:sort-integrations($node/node(), $log) + else if($flag = "sort-transpositions") then + fsort:sort-transpositions($node/node(), $log) else if($flag = "sort-multiphrases") then - fsort:sort-multiphrases($node/node(), $log) - else - error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) + fsort:sort-multiphrases($node/node(), $log) + else if($flag = "sort-certain-anchors") then + fsort:sort-certain-anchors($node/node(), $log) + else + error(QName("FONTANE", "fsort2"), "Invalid flag: " || $flag || "." ) } }; @@ -496,3 +504,34 @@ declare function fsort:sort-multiphrases($nodes as node()*, $log as xs:string) a else fsort:copy-node($node, "sort-multiphrases", $log) }; + +declare function fsort:sort-certain-anchors($nodes as node()*, $log as xs:string) as node()* { + for $node in $nodes return + typeswitch ($node) + + case element(tei:anchor) return + if($node/@next) then + let $corresp-node := fsort:find-corresp-node($node, "next") + return if($corresp-node/preceding-sibling::*[1][self::tei:addSpan[@place = "margin"]]) then + fsort:apply-only-next-node($corresp-node, $log) + else + $node + + else + $node + + default return + if($node[self::text() or self::comment()]) then + $node + + else + fsort:copy-node($node, "sort-certain-anchors", $log) +}; + +declare function fsort:apply-only-next-node($node as node()*, $log as xs:string) as node()* { + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/(@* except @prev), + attribute anchor {"true"}, + fsort:sort-certain-anchors($node/node(), $log) + } +}; -- GitLab From 1f182413071cf8600132773813fcb6f34791485d Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 8 Oct 2019 14:29:09 +0200 Subject: [PATCH 49/97] Fix marginal additions by Fontane --- modules/fontane/edited-text/tei2teisimple.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 94d537a5..7afb4919 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -466,7 +466,7 @@ $log as xs:string) as node()* { element tei:ab { $node/@* } - else if($node/@function = ("placeholder", "etc.", "caret", + else if($node/@function = ("placeholder", "etc.", "footnote-mark", "footnotes", "ellipsis", "paragraph", "verse_marker")) then element tei:ab { attribute type {$node/@function}, -- GitLab From 76cc9416eb2196d8e1dbe80f9b057ef2fd839fa0 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 8 Oct 2019 14:29:37 +0200 Subject: [PATCH 50/97] Fix white spaces, started general white space fixing approach --- modules/fontane/edited-text/tidysimple.xqm | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 464ac013..d1c0ae0d 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -536,6 +536,7 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { if($node/@next and not($node/@prev)) then let $next-node := tidySimple:find-corresp-node($node, "next") let $nodes-inbetween := $node/following-sibling::node()[. << $next-node] + let $nodes-inbetween := ($nodes-inbetween, $node/following::node()[. << $next-node][self::tei:milestone]) let $is-next-node-nested := if($nodes-inbetween/descendant::* = $next-node) then true() @@ -560,6 +561,7 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { else let $next-node := tidySimple:find-corresp-node($node, "next") let $nodes-inbetween := $node/following-sibling::node()[. << $next-node] + let $nodes-inbetween := ($nodes-inbetween, $node/following::node()[. << $next-node][self::tei:milestone]) let $is-next-node-nested := if($nodes-inbetween/descendant::* = $next-node) then true() @@ -779,9 +781,15 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then () else - $node + tidySimple:fix-text($node) + + else if(ends-with($node, "- ") + and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then + tidySimple:fix-text($node) + => functx:right-trim() + else - $node + tidySimple:fix-text($node) case element(tei:milestone) return if($node[@unit = "line"]) then @@ -797,3 +805,29 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { default return tidySimple:copy-element($node, "tidy") }; + +declare function tidySimple:fix-text($node as text()) as text() { + let $special-chars := "\.,\)\?\-!" + let $string := replace($node, " \-", "-") + let $string := + if(ends-with($string, "@@")) then + let $next-char := substring($node/following::text()[1], 1, 1) + return if(matches($next-char, $special-chars)) then + substring($string, 1, string-length($string) - 2) + else + $string + else + $string + let $string := + if(normalize-space($string) = "") then + let $next-char := substring($node/following::text()[1], 1, 1) + return if(matches($next-char, $special-chars)) then + substring($string, 1, string-length($string) - 2) + else + $string + else + $string + + return + text{$string} +}; -- GitLab From 9fbd0dca971b2c2b2e01ed3bf6c51e8d3e70fa38 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 9 Oct 2019 16:25:47 +0200 Subject: [PATCH 51/97] Further work on white space handling --- modules/fontane/edited-text/simple2xhtml.xqm | 42 ++++++++++++----- modules/fontane/edited-text/tidysimple.xqm | 49 ++++++++++++++++---- 2 files changed, 72 insertions(+), 19 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index a2d155f0..727cf126 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -70,14 +70,22 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { if (normalize-space($node) = "") then () else - element xhtml:span { - simple2xhtml:set-hs-info($node, "text"), + ( if($node/preceding-sibling::*[1][self::tei:milestone[@rendition = "indent"]]) then - attribute style {"margin-left: 20px;"} + element xhtml:br {} else (), - simple2xhtml:fix-whitespaces($node) - } + element xhtml:span { + simple2xhtml:set-hs-info($node, "text"), + if($node/preceding-sibling::*[1][self::tei:milestone[@rendition = "indent"]]) then + attribute style {"margin-left: 20px;"} + else if($node/preceding-sibling::*[1][self::tei:milestone[@rendition = "align(center)"]]) then + attribute style {"text-align: center;"} + else + (), + simple2xhtml:fix-whitespaces($node) + } + ) case element(tei:body) return ( @@ -305,6 +313,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { else if($node/@unit = "line") then let $next-char := substring($node/following::text()[1], 1, 1) + let $prev-char := substring($node/preceding::text()[1], 1, 1) return if((matches($next-char, "[\.\)\?,;!]") or $next-char = "“") and not(ends-with($node/preceding::text()[1], "@P"))) then @@ -314,6 +323,9 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { or ends-with($node/preceding::text()[1], "-")) then () + else if(matches($prev-char, "\(")) then + () + else if($node/preceding-sibling::*[1][self::tei:rs[concat('#', @xml:id) = $node/following-sibling::*[2][self::tei:rs]/@prev]]) then () @@ -464,7 +476,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { attribute class {"nb-double-img"} else attribute class {"nb-img"}, - if($node/@rotate) then + (: in case of a 180deg rotation the original width/height + preserved while we have to switch width and height in + case of 90deg/270deg :) + if($node/@rotate = "180") then + attribute style {concat("width: ", $node/parent::*/@width, "; height: ", $node/parent::*/@height, ";")} + else if($node/@rotate) then attribute style {concat("width: ", $node/parent::*/@height, "; height: ", $node/parent::*/@width, ";")} else (), @@ -582,10 +599,13 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ) case element(tei:unclear) return - element xhtml:span { - attribute class {"unclear"}, - simple2xhtml:recursion($node/node()) - } + ( + element xhtml:span { + attribute class {"unclear"}, + simple2xhtml:recursion($node/node()) + }, + text{" "} + ) case element(tei:date) return (simple2xhtml:set-whitespace-before($node), @@ -820,7 +840,7 @@ $mode as xs:string) as element(xhtml:img) { else (), attribute src {$node/@href}, - attribute alt {$node//tei:figDesc/string()}, + attribute alt {$node//tei:figDesc/string() => replace("@@", " ")}, if($mode = "double") then attribute class {"nb-double-img"} else diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index d1c0ae0d..0fc65143 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -519,10 +519,15 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { declare function tidySimple:summarize-entries($node as node()) as node()* { (: the first element of a virtual aggregation:) if($node/@next and not($node/@prev)) then - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/(@* except @next), - tidySimple:apply-all-nexts($node) - } + let $next-node := tidySimple:find-corresp-node($node, "next") + return + if($next-node[self::tei:ab]) then + tidySimple:copy-element($node, "summarize") + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/(@* except @next), + tidySimple:apply-all-nexts($node) + } else if($node/@prev) then () (: nodes that aren't part of the virtual aggregation :) @@ -747,7 +752,13 @@ declare function tidySimple:summarize-hi($nodes as node()*) as node()* { typeswitch ($node) case text() return - $node + (: this should avoid duplicates :) + if($node/ancestor::tei:rs + and $node/preceding-sibling::*[self::tei:hi[@next]] + and $node/preceding-sibling::*[self::tei:hi[@next]]/following-sibling::text()[1] = $node) then + () + else + $node case comment() return $node @@ -785,8 +796,19 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { else if(ends-with($node, "- ") and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then - tidySimple:fix-text($node) - => functx:right-trim() + let $fixed := + tidySimple:fix-text($node) + => functx:right-trim() + return + text{$fixed} + + else if(ends-with($node, "@P ") + and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then + let $fixed := + tidySimple:fix-text($node) + => functx:right-trim() + return + text{$fixed} else tidySimple:fix-text($node) @@ -802,13 +824,24 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { else $node + case element(tei:figure) return + if($node/ancestor::tei:ab) then + tidySimple:copy-element($node, "tidy") + else + () + default return tidySimple:copy-element($node, "tidy") }; declare function tidySimple:fix-text($node as text()) as text() { let $special-chars := "\.,\)\?\-!" - let $string := replace($node, " \-", "-") + let $string := + replace($node, " \-", "-") + => replace("@P ", "@P") + => replace("\[@@", "[") + => replace(" \)", ")") + => replace(" ;", ";") let $string := if(ends-with($string, "@@")) then let $next-char := substring($node/following::text()[1], 1, 1) -- GitLab From f19102ac0f1aea1a998ea93787972aba7dd61f3b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 17 Oct 2019 16:32:01 +0200 Subject: [PATCH 52/97] Fix bug in modal content --- modules/fontane/edited-text/simple2xhtml.xqm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 727cf126..8bfd76d9 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -1080,7 +1080,8 @@ declare function simple2xhtml:tidy($nodes as node()*) as node()* { declare function simple2xhtml:make-modal($node as node()) as element(*)+ { let $content := if($node/ancestor::tei:ab[@type = "sketch"]) then - $node/following-sibling::tei:figDesc/tei:ref//text()[not(ancestor::tei:index)] +(: $node/following-sibling::tei:figDesc/tei:ref//text()[not(ancestor::tei:index)]:) + $node/following-sibling::tei:figDesc//text()[not(ancestor::tei:index)] => string-join(" ") => simple2xhtml:fix-whitespaces() -- GitLab From 9c8e65498be2516242e3923f34fac074d421a07b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 22 Oct 2019 10:46:12 +0200 Subject: [PATCH 53/97] Clear unnecessary tei:seg --- modules/fontane/edited-text/tidysimple.xqm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 0fc65143..318b8ccd 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -830,6 +830,12 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { else () + case element(tei:seg) return + if($node//* or $node//node()) then + tidySimple:copy-element($node, "tidy") + else + () + default return tidySimple:copy-element($node, "tidy") }; -- GitLab From c7849b69f563ad1e7348bc2d64877a70ed4577f6 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 22 Oct 2019 11:15:39 +0200 Subject: [PATCH 54/97] Consider integrations --- modules/fontane/edited-text/tidysimple.xqm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 318b8ccd..b633486d 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -521,7 +521,9 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { if($node/@next and not($node/@prev)) then let $next-node := tidySimple:find-corresp-node($node, "next") return - if($next-node[self::tei:ab]) then + if($next-node[self::tei:ab] + or $next-node[self::tei:seg[@type = "integration"]] + or $node[ancestor-or-self::tei:seg[@type = "integration"]]) then tidySimple:copy-element($node, "summarize") else element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { -- GitLab From cc1fadc3872a7937acaedac5f33ec053a3056348 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 22 Oct 2019 11:24:14 +0200 Subject: [PATCH 55/97] Implement 3.21.10.2.2.2.1.5 --- modules/fontane/edited-text/tei2teisimple.xqm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 7afb4919..35bbebe7 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -671,7 +671,8 @@ $log as xs:string) as node()* { ()) case element(tei:figure) return - if(matches($node/descendant::tei:ref, "Schlusslinie")) + if(matches($node/descendant::tei:ref, "Schlusslinie") + and not(matches($node/descendant::tei:ref, "ehemalig"))) then element tei:ab { switch ($node/descendant::tei:ref) -- GitLab From f97c5bb0a89ba88c17c4948742d0937c80a8d769 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 22 Oct 2019 12:01:04 +0200 Subject: [PATCH 56/97] Let wrong encodings pass --- modules/fontane/edited-text/simple2xhtml.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 8bfd76d9..4d35d520 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -1077,7 +1077,7 @@ declare function simple2xhtml:tidy($nodes as node()*) as node()* { : @param $node a tei:ptr or tei:note[@type = 'authorial'] : @return an icon as xhtml:i and a modal window as xhtml:div :) -declare function simple2xhtml:make-modal($node as node()) as element(*)+ { +declare function simple2xhtml:make-modal($node as node()) as element(*)* { let $content := if($node/ancestor::tei:ab[@type = "sketch"]) then (: $node/following-sibling::tei:figDesc/tei:ref//text()[not(ancestor::tei:index)]:) -- GitLab From 3f0133aef4c5d589d540c0195d1f8c913c71bee7 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 22 Oct 2019 12:49:54 +0200 Subject: [PATCH 57/97] Let erroneous nexts pass --- modules/fontane/edited-text/sort.xqm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 4010d548..8b013e13 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -158,7 +158,10 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no }, fsort:apply-all-nexts($next-node, $log)) else if(not($next-node)) then - fsort:add-log-entry($log, "No next node found for " || $node/@next) + ( + fsort:copy-node($node, "sort", $log), + fsort:add-log-entry($log, "No next node found for " || $node/@next) + ) else fsort:add-log-entry($log, "Several next nodes found for " || $node/@next) -- GitLab From 052fa47a19bb6d8918fc8c783736b727eb7900d2 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 29 Oct 2019 11:17:50 +0100 Subject: [PATCH 58/97] Minor fixes --- modules/fontane/edited-text/tei2teisimple.xqm | 6 +++++ modules/fontane/edited-text/tidysimple.xqm | 24 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 35bbebe7..bd6e1231 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -358,6 +358,12 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } + else if($node/@xml:id) then + element tei:seg { + $node/@*, + fontaneSimple:transform($node/node(), $uri, $log) + } + else fontaneSimple:transform($node/node(), $uri, $log) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index b633486d..ea9ac7b6 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -493,7 +493,13 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { tidySimple:summarize-entries($node) case element(tei:seg) return - tidySimple:summarize-entries($node) + if($node/following-sibling::*[1][self::tei:lb[@type = "edited_text"]] + or $node/following-sibling::*[2][self::tei:lb[@type = "edited_text"]] + or $node/preceding-sibling::*[1][self::tei:lb[@type = "edited_text"]] + or $node/preceding-sibling::*[2][self::tei:lb[@type = "edited_text"]]) then + tidySimple:copy-element($node, "summarize") + else + tidySimple:summarize-entries($node) case element(tei:table) return tidySimple:summarize-entries($node) @@ -531,7 +537,17 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { tidySimple:apply-all-nexts($node) } else if($node/@prev) then - () + let $prev-node := tidySimple:find-corresp-node($node, "prev") + return + (: in some cases we have elements that have been part of a virtual aggregation + but their preceding aggregation element is lost, e.g. in case of a + tei:line pointing to a tei:zone. since we don't keep lines, this + link is lost, but we still want to keep that zone. :) + if($prev-node) then + () + else + tidySimple:copy-element($node, "summarize") + (: nodes that aren't part of the virtual aggregation :) else tidySimple:copy-element($node, "summarize") @@ -833,7 +849,9 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { () case element(tei:seg) return - if($node//* or $node//node()) then + if($node[@type = "verse"] and not($node//text())) then + () + else if($node//* or $node//node()) then tidySimple:copy-element($node, "tidy") else () -- GitLab From 145147db4ee35e08a86ec221dfac39737b779eeb Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 29 Oct 2019 16:30:49 +0100 Subject: [PATCH 59/97] Fix bug in hi summary --- modules/fontane/edited-text/tidysimple.xqm | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index ea9ac7b6..2131c83e 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -529,7 +529,8 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { return if($next-node[self::tei:ab] or $next-node[self::tei:seg[@type = "integration"]] - or $node[ancestor-or-self::tei:seg[@type = "integration"]]) then +(: or $node[ancestor-or-self::tei:seg[@type = "integration"]]:) + ) then tidySimple:copy-element($node, "summarize") else element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { @@ -784,13 +785,25 @@ declare function tidySimple:summarize-hi($nodes as node()*) as node()* { case element(tei:hi) return (: first element of virtual aggregation :) if($node/@next and not($node/@prev)) then - element tei:hi { - $node/(@* except @next), - tidySimple:apply-all-nexts($node) - } + let $next := tidySimple:find-corresp-node($node, "next") + let $nodes-inbetween := $node/following::*[. << $next] + return + if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]]) then + tidySimple:copy-element($node, "summarize-hi") + else + element tei:hi { + $node/(@* except @next), + tidySimple:apply-all-nexts($node) + } (: middle or last element o virutal aggregation:) else if($node/@prev) then - () + let $prev := tidySimple:find-corresp-node($node, "prev") + let $nodes-inbetween := $node/preceding::*[. >> $prev] + return + if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]]) then + tidySimple:copy-element($node, "summarize-hi") + else + () (: not part of virtual aggregation at all :) else tidySimple:copy-element($node, "summarize-hi") -- GitLab From b0c9d6daf14b3874f4af9f225bd1161a5d897d18 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 30 Oct 2019 12:43:53 +0100 Subject: [PATCH 60/97] Fix hyphenation bug --- modules/fontane/edited-text/teisimplehelpers.xqm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 85f59d58..8d7e609e 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -84,9 +84,13 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? { (: and $node/parent::tei:add) then:) (: $node:) (: else :) - if(ends-with($node, "-") and not(simpleHelpers:keep-hyphen($node))) then + if(ends-with($node, "-") + and $node/ancestor::tei:line//text()[last()] = $node + and not(simpleHelpers:keep-hyphen($node))) then text {functx:substring-before-last($node, "-") || "@P"} - else if(ends-with($node, "⸗") and not(simpleHelpers:keep-hyphen($node))) then + else if(ends-with($node, "⸗") + and $node/ancestor::tei:line//text()[last()] = $node + and not(simpleHelpers:keep-hyphen($node))) then text {functx:substring-before-last($node, "⸗") || "@P"} else replace($node, "⸗", "-") -- GitLab From 8c59a20883e0e3e9190abb530b8a11cd3054536b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 30 Oct 2019 12:44:07 +0100 Subject: [PATCH 61/97] Fix white space problem --- modules/fontane/edited-text/tidysimple.xqm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 2131c83e..6731abcb 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -819,8 +819,10 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { case text() return if(normalize-space($node) = "") then - if($node/preceding::*[1][self::tei:milestone[@unit = "line"]] - and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then + if( + ($node/preceding::*[1][self::tei:milestone] + and $node/following::*[1][self::tei:milestone]) + ) then () else tidySimple:fix-text($node) -- GitLab From 22701ce2200628041b3546e35607a7dd0c151e16 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Fri, 1 Nov 2019 14:01:38 +0100 Subject: [PATCH 62/97] Add docs, tidy up a bit --- modules/fontane/edited-text/etTransfo.xqm | 7 + modules/fontane/edited-text/simple2xhtml.xqm | 35 +++- modules/fontane/edited-text/sort.xqm | 8 + modules/fontane/edited-text/tei2teisimple.xqm | 88 +++++--- .../fontane/edited-text/teisimplehelpers.xqm | 11 - modules/fontane/edited-text/tidysimple.xqm | 197 +++++++++--------- 6 files changed, 197 insertions(+), 149 deletions(-) diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index ee675aee..b12f9185 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -481,6 +481,13 @@ declare function etTransfo:report-errors() as item()* { }; +(:~ + : creates the overall TOC by collection information from all Überblickskommentare. + : this info is needed for a separate kind of index in the book. + : + : TODO: fine tuning + : + : @author Michelle Weidling:) declare function etTransfo:create-overall-toc() as element(tei:div) { let $nbs := collection($config:data-root || "/data") let $items := collection($config:data-root || "/data")//tei:TEI/tei:teiHeader//tei:msContents/tei:ab/tei:list[@type="editorial"]/tei:item diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 4d35d520..517f4757 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -957,13 +957,25 @@ as attribute() { }; +(:~ + : Handles the creation of an integration, i.e. authorial comments to some part + : of a text. An integration is rendered as a table with 3 columns in which the + : middle part contains the bracket and the outer ones the text referred to resp. + : the comment if the bracket faces left or right. + : In some cases we have horizontal brackets which we render as a table with + : 3 rows. + : + : @author Michelle Weidling + :) declare function simple2xhtml:make-integration($node as element(tei:seg)) { let $bracket := $node//tei:ab[@function = ("integrate", "authorial_note")] let $orientation := substring-after($bracket/@rend, "bracket_") - (: target is the side where the pointy end of the bracket goes. - corresp is the side where bracket faces to. - example: target { corresp :) + (: + target is the side where the pointy end of the bracket goes. + corresp is the side where bracket faces to. + example: target { corresp + :) let $target-id := replace($bracket/@target, "#", "") let $target := $node//*[@xml:id = $target-id] let $corresp-id := replace($bracket/@corresp, "#", "") @@ -988,6 +1000,12 @@ declare function simple2xhtml:make-integration($node as element(tei:seg)) { }; + +(:~ + : Renders the table for integrations with left or right facing brackets. + : + : @author Michelle Weidling + :) declare function simple2xhtml:make-lr-bracket-integration-table($orientation as xs:string, $corresp as node()*, $target as node()*, $bracket-size as xs:integer) { element xhtml:table { @@ -1025,6 +1043,12 @@ $corresp as node()*, $target as node()*, $bracket-size as xs:integer) { } }; + +(:~ + : Renders the table for integrations with brackets facing down. + : + : @author Michelle Weidling + :) declare function simple2xhtml:make-bottom-bracket-integration-table($corresp as node()*, $target as node()*) { element xhtml:table { @@ -1048,7 +1072,10 @@ $target as node()*) { } }; -(:~ A final tidying of broken white spaces. :) + +(:~ + : A final decluttering of broken white spaces. + : :) declare function simple2xhtml:tidy($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 8b013e13..9a1f92cd 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -508,6 +508,12 @@ declare function fsort:sort-multiphrases($nodes as node()*, $log as xs:string) a fsort:copy-node($node, "sort-multiphrases", $log) }; +(:~ + : In some cases, tei:anchor is also part of a virtual aggregation. This function + : integrates them in into the sorting process. + : + : @author Michelle Weidling + :) declare function fsort:sort-certain-anchors($nodes as node()*, $log as xs:string) as node()* { for $node in $nodes return typeswitch ($node) @@ -531,6 +537,8 @@ declare function fsort:sort-certain-anchors($nodes as node()*, $log as xs:string fsort:copy-node($node, "sort-certain-anchors", $log) }; + + declare function fsort:apply-only-next-node($node as node()*, $log as xs:string) as node()* { element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/(@* except @prev), diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index bd6e1231..d9fec228 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -23,10 +23,7 @@ import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at " (:~ : The main function initiates the transformation of a given notebook. - : - : TODO: adapt to several input files? - : - : :) + :) declare function fontaneSimple:main($doc as node()*, $uri as xs:string, $log as xs:string) as node()? { let $front-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "front_cover")] @@ -990,37 +987,33 @@ as element(tei:pb) { } }; + +(:~ + : The person writing is ofentimes implicit when only the style or the medium + : of the handwriting changes. This function furnishes tei:handShift with all + : information necessary for further processing, i.e. who is currently writing. + : + : @author Michelle Weidling + :) declare function fontaneSimple:enhance-handshift($node as element(tei:handShift)) as element(tei:milestone) { let $prev-hand := $node/preceding::tei:handShift[@new][1] - let $whitespace-before := - if($node/preceding::node()[1][normalize-space(.) = ""] - and string-length($node/preceding::text()[1]) = 1) then - true() - else - false() - - let $whitespace-after := - if($node/following::node()[1][normalize-space(.) = ""] - and string-length($node/following::text()[1]) = 1 - and not($node/following::*[1][@type = "heading"]) - and not($node/following::text()[1][matches(substring(., 1, 1), "[\.,]")])) then - true() - else - false() return element tei:milestone { attribute unit {"handshift"}, attribute subtype {if($node/@new) then $node/@new else $prev-hand/@new}, -(: (if($whitespace-before) then attribute ws-before {"true"} else ()),:) -(: (if($whitespace-after) then attribute ws-after {"true"} else ()),:) - $node/(@* except @new) } }; +(:~ + : Marks an editorial intervention of a piece of text. Editorial interventions are + : renderes as ‹text marked›. + : + : @author Michelle Weidling + :) declare function fontaneSimple:mark-intervention($node as element(*), $uri as xs:string, $log as xs:string) as element(tei:seg) { @@ -1045,6 +1038,13 @@ as element(tei:seg) { } }; + +(:~ + : In some cases a syllable has been forgotten. This funtion marks this circumstance with + : ‹missing-syllable›. + : + : @author Michelle Weidling + :) declare function fontaneSimple:mark-missing-syllable($node as element(*), $uri as xs:string, $log as xs:string) as element(tei:seg) { let $sic := $node/tei:sic/string() @@ -1070,6 +1070,12 @@ xs:string, $log as xs:string) as element(tei:seg) { }; +(:~ + : In some cases a hyohen has been forgotten. This funtion marks this circumstance with + : ‹missing-hyphen›. + : + : @author Michelle Weidling + :) declare function fontaneSimple:mark-missing-hyphen($node as element(tei:lb)) as element(tei:seg) { element tei:seg { @@ -1080,6 +1086,13 @@ element(tei:seg) { } }; + +(:~ + : In some cases text or punctuation has been forgotten. This funtion marks this circumstance with + : ‹text|punctuation›. + : + : @author Michelle Weidling + :) declare function fontaneSimple:mark-supplied($node as element(tei:supplied), $uri as xs:string, $log as xs:string) as element(tei:seg) { element tei:seg { @@ -1116,13 +1129,13 @@ $corresp as node()*) as xs:boolean { false() }; -declare function fontaneSimple:separates-corresp-nodes($node as element(tei:surface)) -as xs:boolean { - some $prev in $node/preceding::*[@next] - satisfies contains($prev/@next, $node/descendant::*/@xml:id) - or contains($prev/@next, $node/following::*/@xml:id) -}; - +(:~ + : Retrieves all necessary information for the index entry in the book + : for each tei:rs we encounter in the text. The info depends on the type of + : reference we face. + : + : @author Michelle Weidling + :) declare function fontaneSimple:make-index-infos($node as element(tei:rs), $index-type as xs:string) as element()* { let $refs := tokenize($node/@ref, " ") @@ -1219,6 +1232,9 @@ $index-type as xs:string) as element()* { } }; + +(:~ + : Creates a tei:term element with all necessary information. :) declare function fontaneSimple:make-term($type as xs:string, $info as xs:string) as element(tei:term)* { if($info != "") then @@ -1230,12 +1246,15 @@ as element(tei:term)* { () }; +(:~ Creates a key for proper sorting in the book. :) declare function fontaneSimple:make-key($index-type as xs:string, $ref as xs:string, $term as xs:string) { let $main := index-info:get-info-about($index-type, $ref, $term) return fontaneSimple:make-key($main) }; + +(:~ Creates a key for proper sorting in the book. Umlauts are normalized and special characters skipped.:) declare function fontaneSimple:make-key($regular-name as xs:string?) { let $name := if(contains($regular-name, ".")) then @@ -1366,6 +1385,9 @@ xs:string, $log as xs:string) as node()* { ()) }; +(:~ Checks if a bibliographic reference has only a tei:ptr as a child. + : @return false() if there's also child::text() + : @return true() if there is no child::text() :) declare function fontaneSimple:has-only-ptr-as-child($bibl as element(tei:bibl)) as xs:boolean { let $text-nodes := $bibl//text() @@ -1383,6 +1405,8 @@ as xs:boolean { true() }; + +(:~ Gets information about "sekundaerliteratur" :) declare function fontaneSimple:get-sec-lit-reference($ptr as element(tei:ptr)) as text() { let $reference := $ptr/@target @@ -1399,6 +1423,8 @@ $message as xs:string) as empty-sequence() { return update insert $entry into doc($log-file)/* }; + +(:~ A generic function for retrieving the TextGridRep/Digilib URL of a given tei:figure :) declare function fontaneSimple:make-img($node as element(tei:figure), $uri as xs:string, $log as xs:string, $flag as xs:string?) as element(tei:figure) { let $display := @@ -1443,7 +1469,7 @@ $log as xs:string, $flag as xs:string?) as element(tei:figure) { } }; - +(:~ Gets the URLs for an image that encompasses two pages :) declare function fontaneSimple:make-double-img($node as element(tei:figure), $uri as xs:string, $log as xs:string) as element(tei:figure)+ { let $left-img-part := fontaneSimple:make-img($node, $uri, $log, "double") @@ -1454,6 +1480,7 @@ $uri as xs:string, $log as xs:string) as element(tei:figure)+ { $right-img-part) }; + declare function fontaneSimple:make-right-img-part($node as element(tei:figure), $uri as xs:string, $log as xs:string) as element(tei:figure) { let $next-id := $node/ancestor::tei:surface/@next @@ -1464,6 +1491,7 @@ $uri as xs:string, $log as xs:string) as element(tei:figure) { fontaneSimple:make-img($corresp-node, $uri, $log, "double") }; + declare function fontaneSimple:make-pb($node as element(tei:surface)) as element(tei:pb)? { let $editorial-list-entries := $node/root()//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:ref let $refs := for $entry in $editorial-list-entries return diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 8d7e609e..44e766ac 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -387,17 +387,6 @@ as xs:boolean { false() }; - -(: TODO :) -(:declare function simpleHelpers:make-section($node as element(tei:milestone)) -as element(tei:section) { - let $id := substring-after($node/@spanTo, "#") - let $corresp := $node/following::*[$id = @xml:id] - let $bla := console:log(util:get-fragment-between($node, $corresp, true(), true())) - return -
-};:) - declare function simpleHelpers:find-chars($node as element(tei:lb)) as node()* { let $prev-line := $node/preceding::tei:line[1] let $prev-last-text := $prev-line/text()[last()] diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 6731abcb..737c15f1 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -52,6 +52,14 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { $final-tei }; + +(:~ Seperates all elements that belong to a valid current hand (i.e. Theodor + : Fontane's or other contemporary writings as well as Friedrich Fontane's TOC + : on calender pages from posthumous ones. While the former are kept, the latter + : are tossed. + : + : @author Michelle Weidling + :) declare function tidySimple:sort-out-invalid-hands($nodes as node()*) as node()* { for $node in $nodes return @@ -103,6 +111,13 @@ as node()* { tidySimple:invalid-hands-default-return($node) }; +(:~ Seperates all elements that belong to a valid current hand (i.e. Theodor + : Fontane's or other contemporary writings as well as Friedrich Fontane's TOC + : on calender pages from posthumous ones. While the former are kept, the latter + : are tossed. + : + : @author Michelle Weidling + :) declare function tidySimple:invalid-hands-default-return($node as node()*) as node()* { let $prev-handshift := $node/preceding::tei:milestone[@unit = "handshift"][1] @@ -144,10 +159,7 @@ as node()* { simpleHelpers:is-prev-hand-same($node)) then () else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } + tidySimple:keep-non-surplus($node) else if($node/@unit = "line" and ($node/ancestor::tei:seg[@type = "missing-hyphen"] @@ -155,90 +167,37 @@ as node()* { () else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:head) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:date) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:rs) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:note) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:abbr) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:list) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - - case element(tei:item) return - if(not($node/* or $node/node())) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } - + tidySimple:keep-non-surplus($node) case element(tei:div) return if($node/@type = "label" and not($node/* or $node/node())) then () else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } + tidySimple:keep-non-surplus($node) default return - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } + if($node[self::tei:item + or self::list + or self::abbr + or self::note + or self::rs + or self::date + or self::head]) then + if(not($node/* or $node/node())) then + () + else + tidySimple:keep-non-surplus($node) + else + tidySimple:keep-non-surplus($node) +}; + + +declare function tidySimple:keep-non-surplus($node as node()*) as node()* { + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } }; declare function tidySimple:has-hand-text($node as element(tei:milestone)) @@ -319,6 +278,7 @@ as element(tei:milestone) { }; +(:~ Enriches a given handshift with all information available. :) declare function tidySimple:enhance-handshifts($nodes as node()*) as node()* { for $node in $nodes return @@ -370,7 +330,12 @@ declare function tidySimple:enhance-medium($node as node(), $medium as xs:string }; - +(:~ In some cases we have headings that are split into two lines and should + : be rendered like that in the edited text. This function finds the heading + : pieces that belong to the upper and lower part and marks them. + : + : @author Michelle Weidling + :) declare function tidySimple:split-headings($nodes as node()*) as node()* { for $node in $nodes return typeswitch($node) @@ -426,6 +391,15 @@ declare function tidySimple:split-headings($nodes as node()*) as node()* { } }; + +(:~ + : In the TEI header all sources Fontane used for a particular notebook are listed + : in tei:derivation. Oftentimes there a simple references to the "sekundaerliteratur" index. + : These index references are expanded in this function to a full string in + : order to list them properly in the book. + : + : @author Michelle Weidling + :) declare function tidySimple:get-Fontanes-sources($header as node()*) { for $node in $header return typeswitch ($node) @@ -461,7 +435,14 @@ declare function tidySimple:get-Fontanes-sources($header as node()*) { }; - +(:~ + : This function summarizes elements that are part of a virtual aggregation into + : a single element, e.g. when we have two or more tei:rs that are about the + : same entity. This way we avoid multiple entries in the indices and multiple + : icons in the online view of the edited text. + : + : @author Michelle Weidling + :) declare function tidySimple:summarize($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -521,7 +502,11 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { }; - +(:~ This function does the actual summary. It is heavily inspired by the sorting + : function in sort.xqm. + : + : @author Michelle Weidling + :) declare function tidySimple:summarize-entries($node as node()) as node()* { (: the first element of a virtual aggregation:) if($node/@next and not($node/@prev)) then @@ -604,25 +589,6 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { }; -declare function tidySimple:exclude-nested-hi($nodes as node()*, $hi-to-exclude as element(tei:hi)) as node()* { - for $node in $nodes return - typeswitch ($node) - case text() return - $node - - case comment() return - $node - - default return - if($node = $hi-to-exclude) then - () - else - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:exclude-nested-hi($node/node(), $hi-to-exclude) - } -}; - declare function tidySimple:find-corresp-node($node as node(), $flag as xs:string) { let $target-id := if($flag = "next") then @@ -674,6 +640,7 @@ declare function tidySimple:get-references-in-abstract($nodes as node()*) as nod }; +(:~ Brings images that encompass two notebook pages into the right order. :) declare function tidySimple:sort-double-imgs($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -702,6 +669,9 @@ declare function tidySimple:sort-double-imgs($nodes as node()*) as node()* { }; +(:~ A function for summarizing headings. This and the other functions of this + : kind are necessary because of the nested nature of XML which leads headings + : to be skipped in tidySimple:summarize. :) declare function tidySimple:summarize-headings($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -733,7 +703,10 @@ declare function tidySimple:summarize-headings($nodes as node()*) as node()* { }; -(:~ A function for summarizing tei:note, especially for authorial notes :) +(:~ A function for summarizing tei:note, especially for authorial notes. + : This and the other functions of this + : kind are necessary because of the nested nature of XML which leads headings + : to be skipped in tidySimple:summarize. :) declare function tidySimple:summarize-notes($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -765,7 +738,9 @@ declare function tidySimple:summarize-notes($nodes as node()*) as node()* { }; -(:~ A function for summarizing tei:hi :) +(:~ A function for summarizing tei:hi. This and the other functions of this + : kind are necessary because of the nested nature of XML which leads headings + : to be skipped in tidySimple:summarize. :) declare function tidySimple:summarize-hi($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -813,6 +788,13 @@ declare function tidySimple:summarize-hi($nodes as node()*) as node()* { }; +(:~ + : After all transforming, sorting, summarizing etc. we have a whole mess of + : unwanted and surplus elements which are handled in this function and tossed + : when appropriate. + : + : @author Michelle Weidling + : :) declare function tidySimple:tidy($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -875,6 +857,13 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { tidySimple:copy-element($node, "tidy") }; + +(:~ + : This function fixes white spaces problems that apply both to the book and the + : online version of the edited text. + : + : @author Michelle Weidling + :) declare function tidySimple:fix-text($node as text()) as text() { let $special-chars := "\.,\)\?\-!" let $string := -- GitLab From 1db27811bbde55cf891614016c93b073ec3ee38a Mon Sep 17 00:00:00 2001 From: mrodzis Date: Fri, 1 Nov 2019 16:25:39 +0100 Subject: [PATCH 63/97] Fix bug in display --- modules/fontane/edited-text/tei2teisimple.xqm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index d9fec228..c164c5c4 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -287,7 +287,7 @@ $log as xs:string) as node()* { else if(matches($node/@style, "underline") - and not(matches($node/@style, "vertical-align"))) then + and not(simpleHelpers:has-valid-style($node)) then fontaneSimple:transform($node/node(), $uri, $log) else if(simpleHelpers:has-valid-style($node) @@ -317,9 +317,6 @@ $log as xs:string) as node()* { else if($node/ancestor::tei:add and $node/@copyOf) then fontaneSimple:mark-intervention($node, $uri, $log) - else if($node/@type = "verse" and $node/@prev) then - () - else if($node/@type = "said") then if($node/@next) then let $next := replace($node/@next, "#", "") -- GitLab From 34383dcc653e8701920e8295788118126d701717 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 4 Nov 2019 12:20:17 +0100 Subject: [PATCH 64/97] Fix bug with hyphens --- modules/fontane/edited-text/teisimplehelpers.xqm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 44e766ac..c36227e7 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -85,7 +85,9 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? { (: $node:) (: else :) if(ends-with($node, "-") - and $node/ancestor::tei:line//text()[last()] = $node + and + ($node/ancestor::tei:line//text()[last()] = $node + or $node/ancestor::*/following-sibling::tei:milestone[@unit = "line"]) and not(simpleHelpers:keep-hyphen($node))) then text {functx:substring-before-last($node, "-") || "@P"} else if(ends-with($node, "⸗") -- GitLab From e78ccab89cf0daaad25dcf79a77333a931fb648c Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 4 Nov 2019 12:21:34 +0100 Subject: [PATCH 65/97] Add missing boolean --- modules/fontane/edited-text/tidysimple.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 737c15f1..a9cc82de 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -550,7 +550,7 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { if($nodes-inbetween/descendant::* = $next-node) then true() else - () + false() return if(count($next-node) = 1) then (tidySimple:summarize($node/node()), -- GitLab From 29ff1d3a2e2bb11d4aca2298745f5cac96a09668 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 6 Nov 2019 07:35:25 +0100 Subject: [PATCH 66/97] Further improvements --- modules/fontane/edited-text/sort.xqm | 30 ++- modules/fontane/edited-text/tei2teisimple.xqm | 103 +++---- modules/fontane/edited-text/tidysimple.xqm | 252 ++++++++++-------- 3 files changed, 195 insertions(+), 190 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 9a1f92cd..887d2420 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -29,7 +29,7 @@ import module namespace functx="http://www.functx.com"; let $fully-sorted := fsort:sort($prepared, $log) let $integrations := fsort:sort-integrations($fully-sorted, $log) let $transpositions := fsort:sort-transpositions($integrations, $log) - let $multiphrases := fsort:sort-multiphrases($integrations, $log) + let $multiphrases := fsort:sort-multiphrases($transpositions, $log) let $id := $tei/@id let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $multiphrases) @@ -144,7 +144,8 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no else (: first element of a virtual aggregation: entry point :) - if($node/@next and not($node/@prev)) then + if($node/@next and not($node/@prev) + or ($node/@next and $node/ancestor::tei:seg[@type = "integration"])) then let $next-node := fsort:find-corresp-node($node, "next") return if(count($next-node) = 1) then @@ -156,7 +157,22 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no element tei:milestone { attribute unit {"line"} }, - fsort:apply-all-nexts($next-node, $log)) + if($next-node/parent::tei:seg/@xml:lang) then + element tei:milestone { + attribute unit {"handfhift"}, + attribute script {"Latn"} + } + else + (), + fsort:apply-all-nexts($next-node, $log), + if($next-node/parent::tei:seg/@xml:lang) then + element tei:milestone { + attribute unit {"handfhift"}, + attribute script {"Latf"} + } + else + () + ) else if(not($next-node)) then ( fsort:copy-node($node, "sort", $log), @@ -508,12 +524,6 @@ declare function fsort:sort-multiphrases($nodes as node()*, $log as xs:string) a fsort:copy-node($node, "sort-multiphrases", $log) }; -(:~ - : In some cases, tei:anchor is also part of a virtual aggregation. This function - : integrates them in into the sorting process. - : - : @author Michelle Weidling - :) declare function fsort:sort-certain-anchors($nodes as node()*, $log as xs:string) as node()* { for $node in $nodes return typeswitch ($node) @@ -537,8 +547,6 @@ declare function fsort:sort-certain-anchors($nodes as node()*, $log as xs:string fsort:copy-node($node, "sort-certain-anchors", $log) }; - - declare function fsort:apply-only-next-node($node as node()*, $log as xs:string) as node()* { element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/(@* except @prev), diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index c164c5c4..d3dc9281 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -23,7 +23,10 @@ import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at " (:~ : The main function initiates the transformation of a given notebook. - :) + : + : TODO: adapt to several input files? + : + : :) declare function fontaneSimple:main($doc as node()*, $uri as xs:string, $log as xs:string) as node()? { let $front-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "front_cover")] @@ -72,7 +75,7 @@ $log as xs:string) as node()* { or $node/ancestor::tei:desc[@type = "edited_text"] or $node/ancestor::tei:note[@type = "editorial"] or $node/ancestor::tei:note[@type = "authorial" and @subtype = ("footnote", "revision", "text")] - or $node/ancestor::tei:seg[@type = "editorial-label"] + or $node/ancestor::tei:seg[@type = ("editorial-label", "integration")] or $node/ancestor::tei:ref[not(matches(@target, "getty") or matches(@target, "xpath"))] or $node/ancestor::tei:seg[@type = "heading"]) then if($node/parent::tei:rs and starts-with($node, " ") @@ -152,10 +155,12 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) else if($node/@place = "above" - and ($node/preceding::node()[1][normalize-space(.) = ""] or $node/ancestor::tei:seg[@type = "transposed"])) then + and ($node/preceding::node()[1][normalize-space(.) = ""] + or $node/ancestor::tei:seg[@type = "transposed"])) then (text{" "}, fontaneSimple:transform($node/node(), $uri, $log), - if($node/ancestor::tei:seg[@type = "transposed"]) then + if($node/following::node()[1][normalize-space(.) = ""] + or $node/ancestor::tei:seg[@type = "transposed"]) then text{" "} else ()) @@ -287,7 +292,7 @@ $log as xs:string) as node()* { else if(matches($node/@style, "underline") - and not(simpleHelpers:has-valid-style($node)) then + and not(simpleHelpers:has-valid-style($node))) then fontaneSimple:transform($node/node(), $uri, $log) else if(simpleHelpers:has-valid-style($node) @@ -317,6 +322,7 @@ $log as xs:string) as node()* { else if($node/ancestor::tei:add and $node/@copyOf) then fontaneSimple:mark-intervention($node, $uri, $log) + else if($node/@type = "said") then if($node/@next) then let $next := replace($node/@next, "#", "") @@ -381,7 +387,7 @@ $log as xs:string) as node()* { text{"@"} else () - ) + ) (: TODO if $node/@type = "highlighted" then make a hi[@type = "vertical-mark"] in the second stage of creating the @@ -786,7 +792,7 @@ $log as xs:string) as node()* { otherwise :) else if($node//text()[matches(., "[\w]")]) then ( - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, if($node/@prev) then () @@ -984,33 +990,37 @@ as element(tei:pb) { } }; - -(:~ - : The person writing is ofentimes implicit when only the style or the medium - : of the handwriting changes. This function furnishes tei:handShift with all - : information necessary for further processing, i.e. who is currently writing. - : - : @author Michelle Weidling - :) declare function fontaneSimple:enhance-handshift($node as element(tei:handShift)) as element(tei:milestone) { let $prev-hand := $node/preceding::tei:handShift[@new][1] + let $whitespace-before := + if($node/preceding::node()[1][normalize-space(.) = ""] + and string-length($node/preceding::text()[1]) = 1) then + true() + else + false() + + let $whitespace-after := + if($node/following::node()[1][normalize-space(.) = ""] + and string-length($node/following::text()[1]) = 1 + and not($node/following::*[1][@type = "heading"]) + and not($node/following::text()[1][matches(substring(., 1, 1), "[\.,]")])) then + true() + else + false() return element tei:milestone { attribute unit {"handshift"}, attribute subtype {if($node/@new) then $node/@new else $prev-hand/@new}, +(: (if($whitespace-before) then attribute ws-before {"true"} else ()),:) +(: (if($whitespace-after) then attribute ws-after {"true"} else ()),:) + $node/(@* except @new) } }; -(:~ - : Marks an editorial intervention of a piece of text. Editorial interventions are - : renderes as ‹text marked›. - : - : @author Michelle Weidling - :) declare function fontaneSimple:mark-intervention($node as element(*), $uri as xs:string, $log as xs:string) as element(tei:seg) { @@ -1035,13 +1045,6 @@ as element(tei:seg) { } }; - -(:~ - : In some cases a syllable has been forgotten. This funtion marks this circumstance with - : ‹missing-syllable›. - : - : @author Michelle Weidling - :) declare function fontaneSimple:mark-missing-syllable($node as element(*), $uri as xs:string, $log as xs:string) as element(tei:seg) { let $sic := $node/tei:sic/string() @@ -1067,12 +1070,6 @@ xs:string, $log as xs:string) as element(tei:seg) { }; -(:~ - : In some cases a hyohen has been forgotten. This funtion marks this circumstance with - : ‹missing-hyphen›. - : - : @author Michelle Weidling - :) declare function fontaneSimple:mark-missing-hyphen($node as element(tei:lb)) as element(tei:seg) { element tei:seg { @@ -1083,13 +1080,6 @@ element(tei:seg) { } }; - -(:~ - : In some cases text or punctuation has been forgotten. This funtion marks this circumstance with - : ‹text|punctuation›. - : - : @author Michelle Weidling - :) declare function fontaneSimple:mark-supplied($node as element(tei:supplied), $uri as xs:string, $log as xs:string) as element(tei:seg) { element tei:seg { @@ -1126,13 +1116,13 @@ $corresp as node()*) as xs:boolean { false() }; -(:~ - : Retrieves all necessary information for the index entry in the book - : for each tei:rs we encounter in the text. The info depends on the type of - : reference we face. - : - : @author Michelle Weidling - :) +declare function fontaneSimple:separates-corresp-nodes($node as element(tei:surface)) +as xs:boolean { + some $prev in $node/preceding::*[@next] + satisfies contains($prev/@next, $node/descendant::*/@xml:id) + or contains($prev/@next, $node/following::*/@xml:id) +}; + declare function fontaneSimple:make-index-infos($node as element(tei:rs), $index-type as xs:string) as element()* { let $refs := tokenize($node/@ref, " ") @@ -1229,9 +1219,6 @@ $index-type as xs:string) as element()* { } }; - -(:~ - : Creates a tei:term element with all necessary information. :) declare function fontaneSimple:make-term($type as xs:string, $info as xs:string) as element(tei:term)* { if($info != "") then @@ -1243,15 +1230,12 @@ as element(tei:term)* { () }; -(:~ Creates a key for proper sorting in the book. :) declare function fontaneSimple:make-key($index-type as xs:string, $ref as xs:string, $term as xs:string) { let $main := index-info:get-info-about($index-type, $ref, $term) return fontaneSimple:make-key($main) }; - -(:~ Creates a key for proper sorting in the book. Umlauts are normalized and special characters skipped.:) declare function fontaneSimple:make-key($regular-name as xs:string?) { let $name := if(contains($regular-name, ".")) then @@ -1382,9 +1366,6 @@ xs:string, $log as xs:string) as node()* { ()) }; -(:~ Checks if a bibliographic reference has only a tei:ptr as a child. - : @return false() if there's also child::text() - : @return true() if there is no child::text() :) declare function fontaneSimple:has-only-ptr-as-child($bibl as element(tei:bibl)) as xs:boolean { let $text-nodes := $bibl//text() @@ -1402,8 +1383,6 @@ as xs:boolean { true() }; - -(:~ Gets information about "sekundaerliteratur" :) declare function fontaneSimple:get-sec-lit-reference($ptr as element(tei:ptr)) as text() { let $reference := $ptr/@target @@ -1420,8 +1399,6 @@ $message as xs:string) as empty-sequence() { return update insert $entry into doc($log-file)/* }; - -(:~ A generic function for retrieving the TextGridRep/Digilib URL of a given tei:figure :) declare function fontaneSimple:make-img($node as element(tei:figure), $uri as xs:string, $log as xs:string, $flag as xs:string?) as element(tei:figure) { let $display := @@ -1466,7 +1443,7 @@ $log as xs:string, $flag as xs:string?) as element(tei:figure) { } }; -(:~ Gets the URLs for an image that encompasses two pages :) + declare function fontaneSimple:make-double-img($node as element(tei:figure), $uri as xs:string, $log as xs:string) as element(tei:figure)+ { let $left-img-part := fontaneSimple:make-img($node, $uri, $log, "double") @@ -1477,7 +1454,6 @@ $uri as xs:string, $log as xs:string) as element(tei:figure)+ { $right-img-part) }; - declare function fontaneSimple:make-right-img-part($node as element(tei:figure), $uri as xs:string, $log as xs:string) as element(tei:figure) { let $next-id := $node/ancestor::tei:surface/@next @@ -1488,7 +1464,6 @@ $uri as xs:string, $log as xs:string) as element(tei:figure) { fontaneSimple:make-img($corresp-node, $uri, $log, "double") }; - declare function fontaneSimple:make-pb($node as element(tei:surface)) as element(tei:pb)? { let $editorial-list-entries := $node/root()//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:ref let $refs := for $entry in $editorial-list-entries return diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index a9cc82de..20de527c 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -52,14 +52,6 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { $final-tei }; - -(:~ Seperates all elements that belong to a valid current hand (i.e. Theodor - : Fontane's or other contemporary writings as well as Friedrich Fontane's TOC - : on calender pages from posthumous ones. While the former are kept, the latter - : are tossed. - : - : @author Michelle Weidling - :) declare function tidySimple:sort-out-invalid-hands($nodes as node()*) as node()* { for $node in $nodes return @@ -111,13 +103,6 @@ as node()* { tidySimple:invalid-hands-default-return($node) }; -(:~ Seperates all elements that belong to a valid current hand (i.e. Theodor - : Fontane's or other contemporary writings as well as Friedrich Fontane's TOC - : on calender pages from posthumous ones. While the former are kept, the latter - : are tossed. - : - : @author Michelle Weidling - :) declare function tidySimple:invalid-hands-default-return($node as node()*) as node()* { let $prev-handshift := $node/preceding::tei:milestone[@unit = "handshift"][1] @@ -159,7 +144,10 @@ as node()* { simpleHelpers:is-prev-hand-same($node)) then () else - tidySimple:keep-non-surplus($node) + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } else if($node/@unit = "line" and ($node/ancestor::tei:seg[@type = "missing-hyphen"] @@ -167,37 +155,90 @@ as node()* { () else - tidySimple:keep-non-surplus($node) + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:head) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:date) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:rs) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:note) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:abbr) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:list) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + + case element(tei:item) return + if(not($node/* or $node/node())) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } + case element(tei:div) return if($node/@type = "label" and not($node/* or $node/node())) then () else - tidySimple:keep-non-surplus($node) + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } default return - if($node[self::tei:item - or self::list - or self::abbr - or self::note - or self::rs - or self::date - or self::head]) then - if(not($node/* or $node/node())) then - () - else - tidySimple:keep-non-surplus($node) - else - tidySimple:keep-non-surplus($node) -}; - - -declare function tidySimple:keep-non-surplus($node as node()*) as node()* { - element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { - $node/@*, - tidySimple:sort-out-surplus-elements($node/node()) - } + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:sort-out-surplus-elements($node/node()) + } }; declare function tidySimple:has-hand-text($node as element(tei:milestone)) @@ -278,7 +319,6 @@ as element(tei:milestone) { }; -(:~ Enriches a given handshift with all information available. :) declare function tidySimple:enhance-handshifts($nodes as node()*) as node()* { for $node in $nodes return @@ -330,12 +370,7 @@ declare function tidySimple:enhance-medium($node as node(), $medium as xs:string }; -(:~ In some cases we have headings that are split into two lines and should - : be rendered like that in the edited text. This function finds the heading - : pieces that belong to the upper and lower part and marks them. - : - : @author Michelle Weidling - :) + declare function tidySimple:split-headings($nodes as node()*) as node()* { for $node in $nodes return typeswitch($node) @@ -372,34 +407,25 @@ declare function tidySimple:split-headings($nodes as node()*) as node()* { default return element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/@*, - if($node/tei:add[@type = "edited_text" and @subtype = "interlinear"]) then - let $add := $node/tei:add[@type = "edited_text" and @subtype = "interlinear"] - return - (element tei:seg{ - attribute type {"upper-part"}, - $add/node() - }, - element tei:lb{ - attribute type {"edited_text"} - }, - element tei:seg{ - attribute type {"lower-part"}, - $add/following-sibling::node() - }) - else +(: if($node/tei:add[@type = "edited_text" and @subtype = "interlinear"]) then:) +(: let $add := $node/tei:add[@type = "edited_text" and @subtype = "interlinear"]:) +(: return:) +(: (element tei:seg{:) +(: attribute type {"upper-part"},:) +(: $add/node():) +(: },:) +(: element tei:lb{:) +(: attribute type {"edited_text"}:) +(: },:) +(: element tei:seg{:) +(: attribute type {"lower-part"},:) +(: $add/following-sibling::node():) +(: }):) +(: else:) tidySimple:split-headings($node/node()) } }; - -(:~ - : In the TEI header all sources Fontane used for a particular notebook are listed - : in tei:derivation. Oftentimes there a simple references to the "sekundaerliteratur" index. - : These index references are expanded in this function to a full string in - : order to list them properly in the book. - : - : @author Michelle Weidling - :) declare function tidySimple:get-Fontanes-sources($header as node()*) { for $node in $header return typeswitch ($node) @@ -435,14 +461,7 @@ declare function tidySimple:get-Fontanes-sources($header as node()*) { }; -(:~ - : This function summarizes elements that are part of a virtual aggregation into - : a single element, e.g. when we have two or more tei:rs that are about the - : same entity. This way we avoid multiple entries in the indices and multiple - : icons in the online view of the edited text. - : - : @author Michelle Weidling - :) + declare function tidySimple:summarize($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -490,33 +509,38 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { default return - if($node/descendant::*[self::tei:milestone[@unit = "line"] - or self::tei:rs - or self::tei:list - or self::tei:item - or self::tei:seg - or self::tei:table][@prev or @next]) then + if(not($node/descendant::*[self::tei:milestone[@unit = "line"]]) + or not($node/descendant::*[self::tei:rs][@prev or @next]) + or not($node/descendant::*[self::tei:list][@prev or @next]) + or not($node/descendant::*[self::tei:item][@prev or @next]) + or not($node/descendant::*[self::tei:seg][@prev or @next]) + or not($node/descendant::*[self::tei:table][@prev or @next])) then tidySimple:copy-element($node, "summarize") else $node }; -(:~ This function does the actual summary. It is heavily inspired by the sorting - : function in sort.xqm. - : - : @author Michelle Weidling - :) + declare function tidySimple:summarize-entries($node as node()) as node()* { (: the first element of a virtual aggregation:) - if($node/@next and not($node/@prev)) then + if(($node/@next and not($node/@prev)) + or ($node/@next and $node/@prev and $node/ancestor::tei:seg[@type = "integration"])) then let $next-node := tidySimple:find-corresp-node($node, "next") + let $prev-node := + if($node/@prev) then + tidySimple:find-corresp-node($node, "prev") + else + () + return if($next-node[self::tei:ab] or $next-node[self::tei:seg[@type = "integration"]] (: or $node[ancestor-or-self::tei:seg[@type = "integration"]]:) ) then tidySimple:copy-element($node, "summarize") + else if($prev-node/ancestor::tei:seg[@type = "integration"]) then + () else element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/(@* except @next), @@ -589,6 +613,25 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { }; +declare function tidySimple:exclude-nested-hi($nodes as node()*, $hi-to-exclude as element(tei:hi)) as node()* { + for $node in $nodes return + typeswitch ($node) + case text() return + $node + + case comment() return + $node + + default return + if($node = $hi-to-exclude) then + () + else + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + tidySimple:exclude-nested-hi($node/node(), $hi-to-exclude) + } +}; + declare function tidySimple:find-corresp-node($node as node(), $flag as xs:string) { let $target-id := if($flag = "next") then @@ -640,7 +683,6 @@ declare function tidySimple:get-references-in-abstract($nodes as node()*) as nod }; -(:~ Brings images that encompass two notebook pages into the right order. :) declare function tidySimple:sort-double-imgs($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -669,9 +711,6 @@ declare function tidySimple:sort-double-imgs($nodes as node()*) as node()* { }; -(:~ A function for summarizing headings. This and the other functions of this - : kind are necessary because of the nested nature of XML which leads headings - : to be skipped in tidySimple:summarize. :) declare function tidySimple:summarize-headings($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -703,10 +742,7 @@ declare function tidySimple:summarize-headings($nodes as node()*) as node()* { }; -(:~ A function for summarizing tei:note, especially for authorial notes. - : This and the other functions of this - : kind are necessary because of the nested nature of XML which leads headings - : to be skipped in tidySimple:summarize. :) +(:~ A function for summarizing tei:note, especially for authorial notes :) declare function tidySimple:summarize-notes($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -738,9 +774,7 @@ declare function tidySimple:summarize-notes($nodes as node()*) as node()* { }; -(:~ A function for summarizing tei:hi. This and the other functions of this - : kind are necessary because of the nested nature of XML which leads headings - : to be skipped in tidySimple:summarize. :) +(:~ A function for summarizing tei:hi :) declare function tidySimple:summarize-hi($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -788,13 +822,6 @@ declare function tidySimple:summarize-hi($nodes as node()*) as node()* { }; -(:~ - : After all transforming, sorting, summarizing etc. we have a whole mess of - : unwanted and surplus elements which are handled in this function and tossed - : when appropriate. - : - : @author Michelle Weidling - : :) declare function tidySimple:tidy($nodes as node()*) as node()* { for $node in $nodes return typeswitch ($node) @@ -848,6 +875,8 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { case element(tei:seg) return if($node[@type = "verse"] and not($node//text())) then () + else if($node[@type = "integration"] and count($node/*) = 2) then + () else if($node//* or $node//node()) then tidySimple:copy-element($node, "tidy") else @@ -857,13 +886,6 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { tidySimple:copy-element($node, "tidy") }; - -(:~ - : This function fixes white spaces problems that apply both to the book and the - : online version of the edited text. - : - : @author Michelle Weidling - :) declare function tidySimple:fix-text($node as text()) as text() { let $special-chars := "\.,\)\?\-!" let $string := -- GitLab From caae531e0be55f031f4192f6aa528bf328a1d9bf Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 7 Nov 2019 15:24:47 +0100 Subject: [PATCH 67/97] Minor improvements --- modules/fontane/edited-text/sort.xqm | 10 +++++----- modules/fontane/edited-text/tei2teisimple.xqm | 12 +++++++----- modules/fontane/edited-text/tidysimple.xqm | 11 ++++++++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 887d2420..bddd5323 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -157,17 +157,17 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no element tei:milestone { attribute unit {"line"} }, - if($next-node/parent::tei:seg/@xml:lang) then + if($next-node/ancestor::tei:seg/@xml:lang) then element tei:milestone { - attribute unit {"handfhift"}, + attribute unit {"handshift"}, attribute script {"Latn"} } else (), fsort:apply-all-nexts($next-node, $log), - if($next-node/parent::tei:seg/@xml:lang) then + if($next-node/ancestor::tei:seg/@xml:lang) then element tei:milestone { - attribute unit {"handfhift"}, + attribute unit {"handshift"}, attribute script {"Latf"} } else @@ -183,7 +183,7 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no (: last of a virtual aggregation: exit point :) else if(not($node/@next)) then - ($node/preceding::tei:handShift[1], + ($node/preceding::*[self::tei:handShift or self::tei:milestone[@unit = "handshift"]][1], fsort:copy-node($node, "sort", $log)) (: element in the middle of a virtual aggregation:) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index d3dc9281..aabfa053 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -78,11 +78,11 @@ $log as xs:string) as node()* { or $node/ancestor::tei:seg[@type = ("editorial-label", "integration")] or $node/ancestor::tei:ref[not(matches(@target, "getty") or matches(@target, "xpath"))] or $node/ancestor::tei:seg[@type = "heading"]) then - if($node/parent::tei:rs and starts-with($node, " ") - and not($node/preceding-sibling::*[1][self::tei:handShift or self::tei:hi]) - and simpleHelpers:is-trimming-necessary($node)) then - simpleHelpers:prepare-text(text{substring-after($node, " ")}) - else +(: if($node/parent::tei:rs and starts-with($node, " "):) +(: and not($node/preceding-sibling::*[1][self::tei:handShift or self::tei:hi]):) +(: and simpleHelpers:is-trimming-necessary($node)) then:) +(: simpleHelpers:prepare-text(text{substring-after($node, " ")}):) +(: else:) simpleHelpers:prepare-text($node) else () @@ -517,6 +517,8 @@ $log as xs:string) as node()* { element tei:div { $node/@type, $node/@xml:id, + $node/@next, + $node/@prev, fontaneSimple:transform($node/node(), $uri, $log) } diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 20de527c..3400a639 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -486,6 +486,9 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { case element(tei:rs) return tidySimple:summarize-entries($node) + case element(tei:div) return + tidySimple:summarize-entries($node) + case element(tei:list) return tidySimple:summarize-entries($node) @@ -536,7 +539,7 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { return if($next-node[self::tei:ab] or $next-node[self::tei:seg[@type = "integration"]] -(: or $node[ancestor-or-self::tei:seg[@type = "integration"]]:) + or $next-node[ancestor-or-self::tei:seg[@type = "integration"]] ) then tidySimple:copy-element($node, "summarize") else if($prev-node/ancestor::tei:seg[@type = "integration"]) then @@ -553,7 +556,9 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { but their preceding aggregation element is lost, e.g. in case of a tei:line pointing to a tei:zone. since we don't keep lines, this link is lost, but we still want to keep that zone. :) - if($prev-node) then + if($prev-node[@type = "vertical-mark"] and not($node[@type = "vertical-mark"])) then + tidySimple:copy-element($node, "summarize") + else if($prev-node) then () else tidySimple:copy-element($node, "summarize") @@ -641,7 +646,7 @@ declare function tidySimple:find-corresp-node($node as node(), $flag as xs:strin else error(QName("FONTANE", "tidySimple001"), "Invalid flag: " || $flag || "." ) return - $node/root()//*[@xml:id = $target-id] + $node/root()//*[@xml:id = $target-id][1] }; -- GitLab From 2de778bc0a3127edd9820c1d33ee4e0e342385e5 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Fri, 15 Nov 2019 13:01:58 +0100 Subject: [PATCH 68/97] Implement alphabetical markers for abbrev index --- modules/fontane/edited-text/abbrev-index.xqm | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/modules/fontane/edited-text/abbrev-index.xqm b/modules/fontane/edited-text/abbrev-index.xqm index 4b31ebfc..40e7cbfe 100644 --- a/modules/fontane/edited-text/abbrev-index.xqm +++ b/modules/fontane/edited-text/abbrev-index.xqm @@ -25,6 +25,7 @@ declare function abbrev-index:main() as element(tei:div) { let $transformed := abbrev-index:transform($file) => abbrev-index:tidy() + => abbrev-index:sort() return element tei:div { @@ -132,3 +133,51 @@ declare function abbrev-index:tidy($nodes as node()*) as node()* { else () }; + + +declare function abbrev-index:sort($nodes as node()*) as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + $node + + case element(tei:row) return + let $first-char := + normalize-space($node/tei:cell[1]/text()) + => substring(1, 1) + => upper-case() + let $prev-first-char := + normalize-space($node/preceding-sibling::tei:row[1]/tei:cell[1]/text()) + => substring(1, 1) + => upper-case() + let $current-row := + element {QName("http://www.tei-c.org/ns/1.0", $node/local-name())} { + $node/@*, + abbrev-index:sort($node/node()) + } + return + if($node[@role = "head"]) then + $current-row + else if(not($first-char = $prev-first-char) + or not($node/preceding-sibling::tei:row[1]) + or $node/preceding-sibling::tei:row[1][@role = "head"]) then + ( + element {QName("http://www.tei-c.org/ns/1.0", $node/local-name())} { + element tei:cell { + attribute type {"lemma"}, + $first-char + }, + element tei:cell {} + }, + $current-row + ) + else + $current-row + + default return + element {QName("http://www.tei-c.org/ns/1.0", $node/local-name())} { + $node/@*, + abbrev-index:sort($node/node()) + } +}; -- GitLab From d8ae38b93667b5672ccf3492a54efa08e18a42b4 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Fri, 15 Nov 2019 15:46:34 +0100 Subject: [PATCH 69/97] Implement backbone for fontane-notizbuecher/print#151/fontane-notizbuecher/print#162 --- modules/fontane/edited-text/etTransfo.xqm | 18 ++++++--- modules/fontane/edited-text/sort.xqm | 39 ++++++++++++++++++- modules/fontane/edited-text/tei2teisimple.xqm | 9 +++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/modules/fontane/edited-text/etTransfo.xqm b/modules/fontane/edited-text/etTransfo.xqm index b12f9185..1a297dd9 100644 --- a/modules/fontane/edited-text/etTransfo.xqm +++ b/modules/fontane/edited-text/etTransfo.xqm @@ -490,28 +490,34 @@ declare function etTransfo:report-errors() as item()* { : @author Michelle Weidling:) declare function etTransfo:create-overall-toc() as element(tei:div) { let $nbs := collection($config:data-root || "/data") - let $items := collection($config:data-root || "/data")//tei:TEI/tei:teiHeader//tei:msContents/tei:ab/tei:list[@type="editorial"]/tei:item + let $items := collection($config:data-root || "/data")//tei:TEI[descendant::tei:title = "Notizbuch E1"]/tei:teiHeader//tei:msContents/tei:ab/tei:list[@type="editorial"]/tei:item let $sortPattern := "^\W+" return element tei:div { attribute type {"overall-toc"}, - let $segs := for $doc in $nbs return + let $segs := + for $doc in $nbs + return let $nb-name := $doc//tei:fileDesc/tei:titleStmt/tei:title[1]/substring-after(., " ") return for $item in $doc//tei:msContents/tei:ab/tei:list[@type="editorial"]//tei:item return - let $refs := $item//tei:ref/@target/string() + let $first-ref := $item//tei:ref[@type = "first"]/@target/string() + let $last-ref := $item//tei:ref[@type = "last"]/@target/string() + let $refs := + for $ref in ($first-ref, $last-ref) return + let $tokens := tokenize($ref, " ") + return $tokens[2] return element tei:seg { attribute type {$nb-name}, attribute source { let $string := for $ref in $refs return - substring-after($ref, "@n='") + substring-after($ref, "@xml:id='") => substring-before("']") return string-join($string, " ") - }, - functx:substring-before-last($item, ")") || ")" + normalize-space(functx:substring-before-last($item, ")") || ")") } return for $seg in $segs order by replace($seg, $sortPattern, "") => substring(1, 1) => upper-case() diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index bddd5323..63b687a4 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -30,10 +30,11 @@ import module namespace functx="http://www.functx.com"; let $integrations := fsort:sort-integrations($fully-sorted, $log) let $transpositions := fsort:sort-transpositions($integrations, $log) let $multiphrases := fsort:sort-multiphrases($transpositions, $log) + let $marked := fsort:mark-referenced-elements($multiphrases, $log) let $id := $tei/@id - let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $multiphrases) - return $multiphrases + let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $marked) + return $marked (: let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $prepared):) (: return $prepared:) }; @@ -554,3 +555,37 @@ declare function fsort:apply-only-next-node($node as node()*, $log as xs:string) fsort:sort-certain-anchors($node/node(), $log) } }; + + +(:~ adds an extra flag for the elements that are referenced in the editorial + : TOC. :) +declare function fsort:mark-referenced-elements($nodes as node()*, $log as xs:string) +as node()* { + for $node in $nodes return + typeswitch ($node) + + case text() return + $node + + case comment() return + $node + + default return + element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { + $node/@*, + let $refs := $node/root()//tei:list[@type = "editorial"]//tei:ref[@type] + let $referenced-ids := + for $ref in $refs return + let $tokens := tokenize($ref/@target, " ") + let $tokens := $tokens[2] + for $token in $tokens return + substring-after($token, "@xml:id='") + => substring-before("']") + return + if($node/@xml:id = $referenced-ids) then + attribute subtype {"referenced"} + else + (), + fsort:mark-referenced-elements($node/node(), $log) + } +}; diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index aabfa053..a7b96d9a 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -489,6 +489,14 @@ $log as xs:string) as node()* { fontaneSimple:mark-intervention($node, $uri, $log) case element(tei:zone) return + ( + if($node/@subtype = "referenced") then + element tei:ab { + $node/@xml:id, + attribute type {"referenced"} + } + else + (), if(matches($node/@style, "border-style:solid") and not(matches($node/@style, "border-radius")) and not($node/@rend = "border-style:house")) then @@ -665,6 +673,7 @@ $log as xs:string) as node()* { else fontaneSimple:transform($node/node(), $uri, $log) + ) case element(tei:said) return (element tei:seg { -- GitLab From 48282b6ae980183adc880be870c398f62f244a5e Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 18 Nov 2019 11:10:41 +0100 Subject: [PATCH 70/97] Add first draft --- modules/fontane/transform.xqm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/fontane/transform.xqm b/modules/fontane/transform.xqm index 4315a426..2bdd55a4 100644 --- a/modules/fontane/transform.xqm +++ b/modules/fontane/transform.xqm @@ -218,9 +218,19 @@ as item()* {( if( config:get("sade.develop") = "true" ) then code:main($node) else code:main($node, false(), "hljs-", true()), + (: for normal tei:surfaces :) for $n in $node/following-sibling::tei:note - where $n >> $node and $n << ($node/following-sibling::tei:surface)[1] - return code:main($n) + where $n >> $node and $n << ($node/following-sibling::tei:surface)[1] + return code:main($n), + (: for tei:surfaces that are part of a "Doppelseitenansicht". + in this case an associated tei:note is encoded after the first/left + tei:surface but should also be displayed on the second/right one. :) + if($node/@prev and $node/preceding-sibling::*[1][self::tei:note]) then + for $n in $node/preceding-sibling::tei:note + where $n >> $node and $n << ($node/preceding-sibling::tei:surface)[1] + return code:main($n) + else + () } } } -- GitLab From e595b5d3582ec44d95624baf99fc9f8285e68582 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 19 Nov 2019 08:36:05 +0100 Subject: [PATCH 71/97] Add indentation for zones --- modules/fontane/edited-text/tei2teisimple.xqm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index a7b96d9a..4f028b4e 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -653,6 +653,12 @@ $log as xs:string) as node()* { or matches($node/@rendition, "roman")) then fontaneSimple:make-seg-with-rendition($node, $uri, $log) + else if($node/@rend = "indent") then + element tei:div { + attribute type {$node/@rend}, + fontaneSimple:transform($node/node(), $uri, $log) + } + else if(not($node/@xml:id)) then fontaneSimple:transform($node/node(), $uri, $log) -- GitLab From d04a8e9dab19cf3e1b1139c92a9f568f68d98055 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 19 Nov 2019 09:50:21 +0100 Subject: [PATCH 72/97] Handle sketches that are part of a virtual aggregation --- modules/fontane/edited-text/tei2teisimple.xqm | 11 +++-------- modules/fontane/edited-text/tidysimple.xqm | 4 +++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 4f028b4e..faf714bd 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -523,10 +523,7 @@ $log as xs:string) as node()* { else if($node/@type = "marked_off") then element tei:div { - $node/@type, - $node/@xml:id, - $node/@next, - $node/@prev, + $node/(@type, @xml:id, @next, @prev), fontaneSimple:transform($node/node(), $uri, $log) } @@ -535,9 +532,7 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) else element tei:hi { - $node/@xml:id, - $node/@prev, - $node/@next, + $node/(@xml:id, @prev, @next), attribute type {"vertical-mark"}, fontaneSimple:transform($node/node(), $uri, $log) } @@ -566,7 +561,7 @@ $log as xs:string) as node()* { ), attribute width {$node/@lrx - $node/@ulx || "cm"}, attribute height {$node/@lry - $node/@uly || "cm"}, - $node/@xml:id, + $node/(@xml:id), fontaneSimple:transform($node/node(), $uri, $log) } else diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 3400a639..ec04a35e 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -528,7 +528,8 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { declare function tidySimple:summarize-entries($node as node()) as node()* { (: the first element of a virtual aggregation:) if(($node/@next and not($node/@prev)) - or ($node/@next and $node/@prev and $node/ancestor::tei:seg[@type = "integration"])) then + or ($node/@next and $node/@prev and $node/ancestor::tei:seg[@type = "integration"]) + or ($node/@next and $node/@prev and tidySimple:find-corresp-node($node, "prev")[self::tei:ab[@type = "sketch"]])) then let $next-node := tidySimple:find-corresp-node($node, "next") let $prev-node := if($node/@prev) then @@ -539,6 +540,7 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { return if($next-node[self::tei:ab] or $next-node[self::tei:seg[@type = "integration"]] + or $next-node[self::tei:ab[@type = "sketch"]] or $next-node[ancestor-or-self::tei:seg[@type = "integration"]] ) then tidySimple:copy-element($node, "summarize") -- GitLab From 3c2d4da27b77c00102ab2ae84abdc2030a46ddc0 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 19 Nov 2019 13:10:38 +0100 Subject: [PATCH 73/97] Fix bug in ws setting --- modules/fontane/edited-text/tei2teisimple.xqm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index faf714bd..eea5c61b 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -155,8 +155,12 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) else if($node/@place = "above" - and ($node/preceding::node()[1][normalize-space(.) = ""] - or $node/ancestor::tei:seg[@type = "transposed"])) then + and + ( + $node/preceding::node()[1][normalize-space(.) = ""] + or $node/ancestor::tei:seg[@type = "transposed"]) + or ends-with($node/preceding-sibling::*[1][self::tei:del], ",") + ) then (text{" "}, fontaneSimple:transform($node/node(), $uri, $log), if($node/following::node()[1][normalize-space(.) = ""] @@ -166,7 +170,13 @@ $log as xs:string) as node()* { ()) else if($node[@place = "superimposed"]) then - fontaneSimple:preserve-whitespace($node, $uri, $log) + ( + if(ends-with($node/preceding-sibling::*[1][self::tei:del], ",")) then + text{" "} + else + (), + fontaneSimple:preserve-whitespace($node, $uri, $log) + ) else if(not($node/@xml:id)) then -- GitLab From ce695e9ae4d7535692478155206a96e06f718bde Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 19 Nov 2019 13:11:06 +0100 Subject: [PATCH 74/97] Turn summarizing lists off --- modules/fontane/edited-text/tidysimple.xqm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index ec04a35e..8f41be0d 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -489,8 +489,8 @@ declare function tidySimple:summarize($nodes as node()*) as node()* { case element(tei:div) return tidySimple:summarize-entries($node) - case element(tei:list) return - tidySimple:summarize-entries($node) +(: case element(tei:list) return:) +(: tidySimple:summarize-entries($node):) case element(tei:item) return tidySimple:summarize-entries($node) -- GitLab From af6d974cd92b6c87b85151e67a67533c893de82c Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 20 Nov 2019 09:33:18 +0100 Subject: [PATCH 75/97] Minor improvements in the creation of the editorial labels --- modules/fontane/edited-text/prepcom.xqm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/fontane/edited-text/prepcom.xqm b/modules/fontane/edited-text/prepcom.xqm index ed5894d3..154d9f9c 100644 --- a/modules/fontane/edited-text/prepcom.xqm +++ b/modules/fontane/edited-text/prepcom.xqm @@ -6,7 +6,7 @@ xquery version "3.1"; : is referenced by an editorial commentary (tei:note[@type = 'editorial']). : : @author Michelle Weidling - : @version 1.0 + : @version 1.1 :) module namespace prepCom="http://fontane-nb.dariah.eu/prepCom"; @@ -153,7 +153,7 @@ as element(tei:seg) { let $label-elements := for $id in $corresp-ids let $id := substring-after($id, "#") - return $node/ancestor::tei:TEI//*[@xml:id = $id] + return $node/root()//*[@xml:id = $id] return if($no-of-elements = 1) then prepCom:create-label-text($label-elements) @@ -183,7 +183,7 @@ as element(tei:seg) { : @return The complete label text :) declare function prepCom:create-label-text($node as node()) as xs:string { - string-join($node/descendant::text(), " ") + string-join($node/descendant::text()[not(parent::tei:expan)], "") => replace("- |⸗ ", "") }; -- GitLab From a252b21a7f1a3a9d9f2ca402f0431435456efd68 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 20 Nov 2019 16:14:15 +0100 Subject: [PATCH 76/97] Improve tidying --- modules/fontane/edited-text/tidysimple.xqm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 8f41be0d..5ab18e6a 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -529,7 +529,7 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { (: the first element of a virtual aggregation:) if(($node/@next and not($node/@prev)) or ($node/@next and $node/@prev and $node/ancestor::tei:seg[@type = "integration"]) - or ($node/@next and $node/@prev and tidySimple:find-corresp-node($node, "prev")[self::tei:ab[@type = "sketch"]])) then + or ($node/@next and $node/@prev and tidySimple:find-corresp-node($node, "prev")[self::tei:ab[@type = "sketch"] or self::tei:anchor])) then let $next-node := tidySimple:find-corresp-node($node, "next") let $prev-node := if($node/@prev) then @@ -541,7 +541,8 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { if($next-node[self::tei:ab] or $next-node[self::tei:seg[@type = "integration"]] or $next-node[self::tei:ab[@type = "sketch"]] - or $next-node[ancestor-or-self::tei:seg[@type = "integration"]] + or $next-node[ancestor-or-self::tei:seg[@type = "integration"]][not(local-name(.) = ("rs", "item", "seg"))] + or $next-node[descendant::tei:seg[@type = "integration"]][not(local-name(.) = ("rs", "item", "seg"))] ) then tidySimple:copy-element($node, "summarize") else if($prev-node/ancestor::tei:seg[@type = "integration"]) then -- GitLab From a9e0826d8b40cb0768b07bc4fd277e2b104a8347 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 20 Nov 2019 16:14:58 +0100 Subject: [PATCH 77/97] Consider hyphens that have been at the end of a line (but aren't after sorting) --- modules/fontane/edited-text/teisimplehelpers.xqm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index c36227e7..8d90d11e 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -84,16 +84,21 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? { (: and $node/parent::tei:add) then:) (: $node:) (: else :) - if(ends-with($node, "-") + if(ends-with($node, "-") and ($node/ancestor::tei:line//text()[last()] = $node + or $node/ancestor::tei:rs[@next]//text()[last()] = $node or $node/ancestor::*/following-sibling::tei:milestone[@unit = "line"]) and not(simpleHelpers:keep-hyphen($node))) then - text {functx:substring-before-last($node, "-") || "@P"} + text {functx:substring-before-last($node, "-") || "@P"} + else if(ends-with($node, "⸗") - and $node/ancestor::tei:line//text()[last()] = $node - and not(simpleHelpers:keep-hyphen($node))) then - text {functx:substring-before-last($node, "⸗") || "@P"} + and + ($node/ancestor::tei:line//text()[last()] = $node + or $node/ancestor::tei:rs[@next]//text()[last()] = $node + or $node/ancestor::*/following-sibling::tei:milestone[@unit = "line"]) + and not(simpleHelpers:keep-hyphen($node))) then + text {functx:substring-before-last($node, "⸗") || "@P"} else replace($node, "⸗", "-") let $save-whitespaces := replace($cleared-end-hyphen, " ", "@@") -- GitLab From 6c9fde9a3ea18a6f15180183881baabff35a9a57 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 20 Nov 2019 16:15:26 +0100 Subject: [PATCH 78/97] Remove surplus code; improve handling of tei:add --- modules/fontane/edited-text/tei2teisimple.xqm | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index eea5c61b..82fb84ba 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -155,19 +155,23 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) else if($node/@place = "above" - and +(: and :) +(: ( :) +(: $node/preceding::node()[1][normalize-space(.) = ""]:) +(: or $node/ancestor::tei:seg[@type = "transposed"]):) +(: or ends-with($node/preceding-sibling::*[1][self::tei:del], ","):) + ) + then ( - $node/preceding::node()[1][normalize-space(.) = ""] - or $node/ancestor::tei:seg[@type = "transposed"]) - or ends-with($node/preceding-sibling::*[1][self::tei:del], ",") - ) then - (text{" "}, - fontaneSimple:transform($node/node(), $uri, $log), - if($node/following::node()[1][normalize-space(.) = ""] - or $node/ancestor::tei:seg[@type = "transposed"]) then - text{" "} - else - ()) + text{" "}, + fontaneSimple:transform($node/node(), $uri, $log), + if($node/following::node()[1][normalize-space(.) = ""] + or $node/ancestor::tei:seg[@type = "transposed"] + or matches(substring($node/following::text()[1],1 ,1), "[A-Z]")) then + text{" "} + else + () + ) else if($node[@place = "superimposed"]) then ( @@ -515,13 +519,6 @@ $log as xs:string) as node()* { fontaneSimple:transform($node/node(), $uri, $log) } - else if($node/@points and $node//tei:figure) then - element tei:div { - $node/@*, - attribute type {"genealogy"}, - fontaneSimple:transform($node/node(), $uri, $log) - } - else if(matches($node/@rend, "border-bottom-style:brace")) then (fontaneSimple:transform($node/node(), $uri, $log), element tei:ab { -- GitLab From fc5fad1f472e1422042cd8b6ecd9a011f6f133c8 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Wed, 20 Nov 2019 16:15:38 +0100 Subject: [PATCH 79/97] Consider tei:anchor when sorting --- modules/fontane/edited-text/sort.xqm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 63b687a4..e7d54081 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -72,6 +72,9 @@ declare function fsort:sort($nodes as node()*, $log as xs:string) { case element(tei:abbr) return fsort:default-return($node, $log) + case element(tei:anchor) return + fsort:default-return($node, $log) + default return fsort:copy-node($node, "sort", $log) }; -- GitLab From 67ceb3937bef829d45390933358608b5f23912d3 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 21 Nov 2019 17:48:18 +0100 Subject: [PATCH 80/97] Minor improvements in performance and img rotation --- modules/fontane/edited-text/tei2teisimple.xqm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 82fb84ba..a5ef4ba5 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -148,7 +148,7 @@ $log as xs:string) as node()* { else if($node/@cause ="catchword") then () - else if($node[replace($node/@copyOf, "#", "") = $node/ancestor::tei:TEI//tei:seg/@xml:id]) then + else if($node[replace($node/@copyOf, "#", "") = $node/root()//tei:seg/@xml:id]) then fontaneSimple:mark-intervention($node, $uri, $log) else if($node/@rend ="|") then @@ -163,7 +163,10 @@ $log as xs:string) as node()* { ) then ( - text{" "}, + if(not($node/preceding-sibling::node()[1][self::text()][matches(substring(string-length(.), 1, 1), "[a-z]")])) then + text{" "} + else + (), fontaneSimple:transform($node/node(), $uri, $log), if($node/following::node()[1][normalize-space(.) = ""] or $node/ancestor::tei:seg[@type = "transposed"] @@ -1433,9 +1436,8 @@ $log as xs:string, $flag as xs:string?) as element(tei:figure) { else $img-url let $rotation := - (: no children and comment right after element:) - if($node/following-sibling::node()[1][self::comment()][matches(./string(), "rotate")] - and not($node/child::*)) then + (: comment right after element:) + if($node/following-sibling::node()[1][self::comment()][matches(./string(), "rotate")]) then substring-after($node/following::comment()[1], "rotate(") => substring-before("deg") (: comment as first descendant :) -- GitLab From d3ff2c0079f895c9be7553c5fa0a8a054b7525cc Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 21 Nov 2019 17:51:04 +0100 Subject: [PATCH 81/97] Fix bug in tei:add --- modules/fontane/edited-text/tei2teisimple.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index a5ef4ba5..adf79fa1 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -163,7 +163,7 @@ $log as xs:string) as node()* { ) then ( - if(not($node/preceding-sibling::node()[1][self::text()][matches(substring(string-length(.), 1, 1), "[a-z]")])) then + if(not($node/preceding-sibling::node()[1][self::text()][matches(substring(., string-length(.), 1), "[a-z]")])) then text{" "} else (), -- GitLab From a18ad1abee46b940f02aca4fc8590d49b4b3565f Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 10:13:42 +0100 Subject: [PATCH 82/97] Save handShift when it's the last child of a sorted element --- modules/fontane/edited-text/sort.xqm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index e7d54081..5a83a434 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -106,8 +106,12 @@ declare function fsort:default-return($node as node(), $log as xs:string) as nod this doesn't hold for the ones with a @anchor, since they are the first real element of a virtual aggregation that has been started by an anchor when we have an addition in a page's margin (3.21.13.3) :) - else if($node[@prev] and not($node/@anchor = "true")) then - () + else if($node[@prev] + and not($node/@anchor = "true")) then + if($node/descendant::*[last()][self::tei:handShift]) then + fsort:copy-node($node/descendant::*[last()][self::tei:handShift], "sort", $log) + else + () (: we distinguish this case and the one below to improve performance :) else if($node[descendant::*[@next or @prev]]) then -- GitLab From 0392735822c6735ff7ae8607a3bfbd0ea72954b7 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 10:13:57 +0100 Subject: [PATCH 83/97] Fix bug in handshifts --- modules/fontane/edited-text/tei2teisimple.xqm | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index adf79fa1..3bbed796 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -163,7 +163,8 @@ $log as xs:string) as node()* { ) then ( - if(not($node/preceding-sibling::node()[1][self::text()][matches(substring(., string-length(.), 1), "[a-z]")])) then + if(not($node/preceding-sibling::node()[1][self::text()][matches(substring(., string-length(.), 1), "[a-z]")]) + and not($node/preceding-sibling::*[1][self::tei:del])) then text{" "} else (), @@ -475,6 +476,10 @@ $log as xs:string) as node()* { case element(tei:milestone) return if($node/@unit = "illustration") then () + (: during sort.xqm we already create handshifts, but they lack + information about who if the author. :) + else if($node/@unit = "handshift") then + fontaneSimple:enhance-handshift($node) else fontaneSimple:copy-element($node, $uri, $log) @@ -1012,33 +1017,17 @@ as element(tei:pb) { } }; -declare function fontaneSimple:enhance-handshift($node as element(tei:handShift)) + +declare function fontaneSimple:enhance-handshift($node as element(*)) as element(tei:milestone) { let $prev-hand := $node/preceding::tei:handShift[@new][1] - let $whitespace-before := - if($node/preceding::node()[1][normalize-space(.) = ""] - and string-length($node/preceding::text()[1]) = 1) then - true() - else - false() - - let $whitespace-after := - if($node/following::node()[1][normalize-space(.) = ""] - and string-length($node/following::text()[1]) = 1 - and not($node/following::*[1][@type = "heading"]) - and not($node/following::text()[1][matches(substring(., 1, 1), "[\.,]")])) then - true() - else - false() return element tei:milestone { attribute unit {"handshift"}, attribute subtype {if($node/@new) then $node/@new else $prev-hand/@new}, -(: (if($whitespace-before) then attribute ws-before {"true"} else ()),:) -(: (if($whitespace-after) then attribute ws-after {"true"} else ()),:) - $node/(@* except @new) + $node/(@* except (@new, @unit)) } }; -- GitLab From 703cb18e793e6e8fd5d12dd4237c2f3053fc99c8 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 10:14:17 +0100 Subject: [PATCH 84/97] Fix bug in hyphen handling --- modules/fontane/edited-text/teisimplehelpers.xqm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 8d90d11e..828263a0 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -86,7 +86,7 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? { (: else :) if(ends-with($node, "-") and - ($node/ancestor::tei:line//text()[last()] = $node + ($node/ancestor::tei:line//text()[not(normalize-space(.) = "")][last()] = $node or $node/ancestor::tei:rs[@next]//text()[last()] = $node or $node/ancestor::*/following-sibling::tei:milestone[@unit = "line"]) and not(simpleHelpers:keep-hyphen($node))) then @@ -94,7 +94,7 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? { else if(ends-with($node, "⸗") and - ($node/ancestor::tei:line//text()[last()] = $node + ($node/ancestor::tei:line//text()[not(normalize-space(.) = "")][last()] = $node or $node/ancestor::tei:rs[@next]//text()[last()] = $node or $node/ancestor::*/following-sibling::tei:milestone[@unit = "line"]) and not(simpleHelpers:keep-hyphen($node))) then -- GitLab From f30e3b239fbf0916b9c9252f3d0aeb9adec5960b Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 10:15:03 +0100 Subject: [PATCH 85/97] Minor improvements --- modules/fontane/edited-text/tidysimple.xqm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 5ab18e6a..838f83fd 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -529,7 +529,7 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { (: the first element of a virtual aggregation:) if(($node/@next and not($node/@prev)) or ($node/@next and $node/@prev and $node/ancestor::tei:seg[@type = "integration"]) - or ($node/@next and $node/@prev and tidySimple:find-corresp-node($node, "prev")[self::tei:ab[@type = "sketch"] or self::tei:anchor])) then + or ($node/@next and $node/@prev and tidySimple:find-corresp-node($node, "prev")[self::tei:ab[@type = "sketch"] or self::tei:anchor or self::tei:head])) then let $next-node := tidySimple:find-corresp-node($node, "next") let $prev-node := if($node/@prev) then @@ -735,11 +735,13 @@ declare function tidySimple:summarize-headings($nodes as node()*) as node()* { let $corresp-node := tidySimple:find-corresp-node($node, "next") return - element tei:head { - $node/@*, - $node/node(), - $corresp-node/node() - } + if($corresp-node[self::tei:seg]) then + element tei:head { + $node/@*, + $node/node() + } + else + $node else if($node/@prev) then () else @@ -867,7 +869,8 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { if($node[@unit = "line"]) then if(($node/following::node()[1][self::tei:milestone[@unit = "line"]] or normalize-space($node/following::node()[1]) = "") - and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then + and $node/following::*[1][self::tei:milestone[@unit = "line"]] + or $node/following::*[1][self::tei:milestone[@unit = "handshift"]]) then () else $node -- GitLab From 3ae0fee5e061fcb37e20ecaba49ffcc6e23d156c Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 12:53:27 +0100 Subject: [PATCH 86/97] =?UTF-8?q?Kalenderbl=C3=A4tter=20aren't=20that=20im?= =?UTF-8?q?portant,=20TOCs=20are.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/fontane/edited-text/teisimplehelpers.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 828263a0..6a7086b4 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -311,7 +311,7 @@ $node as element(tei:milestone)) as xs:boolean { let $current-hand := replace($node/@subtype, "#", "") return if(functx:is-value-in-sequence($current-hand, $hands) - or ($node/ancestor::*[@type = ("label", "toc", "Kalenderblatt")] + or ($node/ancestor::*[@type = ("label", "toc")] and matches($current-hand, "Friedrich_Fontane")) ) then true() -- GitLab From 5f310657e81ad63fd57b94268d0885b6cdefb8ad Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 12:53:52 +0100 Subject: [PATCH 87/97] Tidy up some more --- modules/fontane/edited-text/tidysimple.xqm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 838f83fd..64da95ec 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -869,11 +869,13 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { if($node[@unit = "line"]) then if(($node/following::node()[1][self::tei:milestone[@unit = "line"]] or normalize-space($node/following::node()[1]) = "") - and $node/following::*[1][self::tei:milestone[@unit = "line"]] - or $node/following::*[1][self::tei:milestone[@unit = "handshift"]]) then + and $node/following::*[1][self::tei:milestone[@unit = "line"]]) then () else $node + else if($node[@unit = "line"] + and $node/following::node()[1][self::tei:milestone[@unit = "handshift"]]) then + () else $node -- GitLab From 6c15d1f2795ef1cfbd252a4c5463166cb8270b90 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Mon, 25 Nov 2019 12:54:26 +0100 Subject: [PATCH 88/97] Minor improvements --- modules/fontane/edited-text/tei2teisimple.xqm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 3bbed796..730baeaf 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -24,8 +24,6 @@ import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at " (:~ : The main function initiates the transformation of a given notebook. : - : TODO: adapt to several input files? - : : :) declare function fontaneSimple:main($doc as node()*, $uri as xs:string, $log as xs:string) as node()? { @@ -154,7 +152,7 @@ $log as xs:string) as node()* { else if($node/@rend ="|") then fontaneSimple:transform($node/node(), $uri, $log) - else if($node/@place = "above" + else if($node/@place = ("above", "below") (: and :) (: ( :) (: $node/preceding::node()[1][normalize-space(.) = ""]:) @@ -460,8 +458,14 @@ $log as xs:string) as node()* { () else if(simpleHelpers:is-page($node)) then - (text{" "}, - fontaneSimple:transform($node/node(), $uri, $log)) + ( + if(ends-with($node//text()[matches(., "[\w]")][last()], "-") + or ends-with($node//text()[matches(., "[\w]")][last()], "⸗")) then + () + else + text{" "}, + fontaneSimple:transform($node/node(), $uri, $log) + ) else if($node/@type = "label" and (contains($node/@subtype, "Fontane") @@ -764,7 +768,7 @@ $log as xs:string) as node()* { case element(tei:note) return if($node/@type = "authorial" - and not($node/@subtype = ("footnote", "revision", "text"))) then + and not($node/@subtype = ("footnote", "text"))) then () else fontaneSimple:copy-element($node, $uri, $log) -- GitLab From 179c4761a338ab695af44cc42b73388c2ead95f5 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 25 Nov 2019 17:43:07 +0100 Subject: [PATCH 89/97] Tidy up unnecessary divs --- modules/fontane/edited-text/tidysimple.xqm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 64da95ec..f78daa88 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -895,6 +895,12 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { else () + case element(tei:div) return + if($node//text()[not(normalize-space(.) = "")]) then + tidySimple:copy-element($node, "tidy") + else + () + default return tidySimple:copy-element($node, "tidy") }; -- GitLab From 8f8acf415e16b36feb81d7f466666c33ddba07e3 Mon Sep 17 00:00:00 2001 From: Michelle Weidling Date: Mon, 25 Nov 2019 17:43:26 +0100 Subject: [PATCH 90/97] Skip unnecessary attachments --- modules/fontane/edited-text/tei2teisimple.xqm | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 730baeaf..509d19b7 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -471,6 +471,7 @@ $log as xs:string) as node()* { (contains($node/@subtype, "Fontane") or contains($node/@subtype, "Hersteller") or contains($node/@subtype, "Firmen")) + and not($node/@attachment = "glued-posthumous") ) then fontaneSimple:make-div($node, $uri, $log) -- GitLab From 5bd03656d0bc4d7fcbf2529d75caf83578b89803 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 26 Nov 2019 17:23:56 +0100 Subject: [PATCH 91/97] Fix bug in summarizing hi --- modules/fontane/edited-text/tidysimple.xqm | 86 ++++++++++++++-------- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index f78daa88..1a98008a 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -30,7 +30,8 @@ declare variable $tidySimple:valid-hands := declare function tidySimple:main($tei as node()*, $uri as xs:string) { - let $tidy := tidySimple:enhance-handshifts($tei//tei:text) +(: let $tidy := tidySimple:enhance-handshifts($tei//tei:text):) + let $tidy := tidySimple:enhance-handshifts($tei) => tidySimple:sort-out-surplus-elements() => tidySimple:sort-out-invalid-hands() => tidySimple:split-headings() @@ -46,7 +47,7 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) { let $id-parts := tokenize($tei//tei:TEI/@id, " ") let $key1 := substring($id-parts[2], 1, 1) let $key2 := substring($id-parts[2], 2) - let $final-tei := {$header}{$tidy} + let $final-tei := {$header}{$tidy//tei:text} let $store := xmldb:store($config:data-root || "/print/xml/", $uri || ".xml", $final-tei) return $final-tei @@ -543,6 +544,7 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { or $next-node[self::tei:ab[@type = "sketch"]] or $next-node[ancestor-or-self::tei:seg[@type = "integration"]][not(local-name(.) = ("rs", "item", "seg"))] or $next-node[descendant::tei:seg[@type = "integration"]][not(local-name(.) = ("rs", "item", "seg"))] + or not(local-name($node) = local-name($next-node)) ) then tidySimple:copy-element($node, "summarize") else if($prev-node/ancestor::tei:seg[@type = "integration"]) then @@ -550,7 +552,7 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { else element {QName("http://www.tei-c.org/ns/1.0", $node/name())} { $node/(@* except @next), - tidySimple:apply-all-nexts($node) + tidySimple:apply-all-nexts($node, "summarize") } else if($node/@prev) then let $prev-node := tidySimple:find-corresp-node($node, "prev") @@ -559,7 +561,8 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { but their preceding aggregation element is lost, e.g. in case of a tei:line pointing to a tei:zone. since we don't keep lines, this link is lost, but we still want to keep that zone. :) - if($prev-node[@type = "vertical-mark"] and not($node[@type = "vertical-mark"])) then + if($prev-node[@type = "vertical-mark"] and not($node[@type = "vertical-mark"]) + or not(local-name($node) = local-name($prev-node))) then tidySimple:copy-element($node, "summarize") else if($prev-node) then () @@ -572,7 +575,8 @@ declare function tidySimple:summarize-entries($node as node()) as node()* { }; -declare function tidySimple:apply-all-nexts($node as node()) as node()* { +declare function tidySimple:apply-all-nexts($node as node(), $flag as xs:string) +as node()* { (: entry point of virtual aggregation:) if($node/@next and not($node/@prev)) then let $next-node := tidySimple:find-corresp-node($node, "next") @@ -585,18 +589,29 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { false() return if(count($next-node) = 1) then - (tidySimple:summarize($node/node()), - $nodes-inbetween, - if($is-next-node-nested) then - () - else - tidySimple:apply-all-nexts($next-node)) + ( + if($flag = "hi") then + tidySimple:summarize-hi($node/node()) + else + tidySimple:summarize($node/node()), + $nodes-inbetween, + if($is-next-node-nested) then + () + else + tidySimple:apply-all-nexts($next-node, $flag) + ) else - tidySimple:summarize($node/node()) + if($flag = "hi") then + tidySimple:summarize-hi($node/node()) + else + tidySimple:summarize($node/node()) (: last of a virtual aggregation: exit point :) else if(not($node/@next)) then - tidySimple:summarize($node/node()) + if($flag = "hi") then + tidySimple:summarize-hi($node/node()) + else + tidySimple:summarize($node/node()) (: element in the middle of a virtual aggregation:) else @@ -610,14 +625,22 @@ declare function tidySimple:apply-all-nexts($node as node()) as node()* { () return if(count($next-node) = 1) then - (tidySimple:summarize($node/node()), - $nodes-inbetween, - if($is-next-node-nested) then - () - else - tidySimple:apply-all-nexts($next-node)) + ( + if($flag = "hi") then + tidySimple:summarize-hi($node/node()) + else + tidySimple:summarize($node/node()), + $nodes-inbetween, + if($is-next-node-nested) then + () + else + tidySimple:apply-all-nexts($next-node, $flag) + ) else - tidySimple:summarize($node/node()) + if($flag = "hi") then + tidySimple:summarize-hi($node/node()) + else + tidySimple:summarize($node/node()) }; @@ -807,22 +830,27 @@ declare function tidySimple:summarize-hi($nodes as node()*) as node()* { let $next := tidySimple:find-corresp-node($node, "next") let $nodes-inbetween := $node/following::*[. << $next] return - if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]]) then + if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]] + or $next/ancestor::* = $node) then tidySimple:copy-element($node, "summarize-hi") else element tei:hi { $node/(@* except @next), - tidySimple:apply-all-nexts($node) + tidySimple:apply-all-nexts($node, "hi") } (: middle or last element o virutal aggregation:) else if($node/@prev) then - let $prev := tidySimple:find-corresp-node($node, "prev") - let $nodes-inbetween := $node/preceding::*[. >> $prev] - return - if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]]) then - tidySimple:copy-element($node, "summarize-hi") - else - () + if(tidySimple:find-corresp-node($node, "prev") = $node/ancestor::*) then + () + else + let $prev := tidySimple:find-corresp-node($node, "prev") + let $nodes-inbetween := $node/preceding::*[. >> $prev] + return + if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]] + or not(local-name($node) = local-name($prev))) then + tidySimple:copy-element($node, "summarize-hi") + else + () (: not part of virtual aggregation at all :) else tidySimple:copy-element($node, "summarize-hi") -- GitLab From 1c209ec9fa0d0abe7fe7ea889526b8f6ac01751a Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 26 Nov 2019 17:24:37 +0100 Subject: [PATCH 92/97] Improve handShift assessment --- modules/fontane/edited-text/teisimplehelpers.xqm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/teisimplehelpers.xqm b/modules/fontane/edited-text/teisimplehelpers.xqm index 6a7086b4..b44c662d 100644 --- a/modules/fontane/edited-text/teisimplehelpers.xqm +++ b/modules/fontane/edited-text/teisimplehelpers.xqm @@ -310,7 +310,7 @@ declare function simpleHelpers:is-hand-valid($hands as xs:string*, $node as element(tei:milestone)) as xs:boolean { let $current-hand := replace($node/@subtype, "#", "") return - if(functx:is-value-in-sequence($current-hand, $hands) + if($node/root()//tei:handNote[@xml:id = $current-hand]/@script = "contemporary" or ($node/ancestor::*[@type = ("label", "toc")] and matches($current-hand, "Friedrich_Fontane")) ) then -- GitLab From 5a5e0796cb0e1c921b24e847e489a9c62676e84a Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 26 Nov 2019 17:25:16 +0100 Subject: [PATCH 93/97] Improve return type and tei:add --- modules/fontane/edited-text/tei2teisimple.xqm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index 509d19b7..a6864142 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -26,7 +26,7 @@ import module namespace index-info="http://fontane-nb.dariah.eu/index-info" at " : : :) declare function fontaneSimple:main($doc as node()*, $uri as xs:string, $log as -xs:string) as node()? { +xs:string) as element(tei:teiCorpus) { let $front-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "front_cover")] let $back-covers := $doc//tei:sourceDoc/tei:surface[contains(@n, "back_cover")] let $content := ($doc//tei:sourceDoc/tei:surface[not(contains(@n, "cover") @@ -181,7 +181,7 @@ $log as xs:string) as node()* { text{" "} else (), - fontaneSimple:preserve-whitespace($node, $uri, $log) + fontaneSimple:transform($node/node(), $uri, $log) ) -- GitLab From 9af25dd1f131aaf7cc965a194a8646e3ebf9dd5e Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 26 Nov 2019 17:25:58 +0100 Subject: [PATCH 94/97] Remove surplus code; improve handShift handling --- modules/fontane/edited-text/sort.xqm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 5a83a434..8305d84b 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -35,8 +35,6 @@ import module namespace functx="http://www.functx.com"; let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $marked) return $marked -(: let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-sorted.xml", $prepared):) -(: return $prepared:) }; @@ -311,8 +309,13 @@ as node()* { else attribute medium {$node/preceding::tei:handShift[@medium][1]/@medium}, - if($node/@script) then + if($node/@script + and (matches($node/@script, "Lat") or matches($node/@script, "Druck"))) then $node/@script + else if($node/@script) then + let $prev-hs := $node/preceding::tei:handShift[1]/@script + return + string-join(($node/@script, $prev-hs), " ") else attribute script {$node/preceding::tei:handShift[@script][1]/@script} } -- GitLab From 5f6654763eec74cb546c89826845fce61f3733b5 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Tue, 26 Nov 2019 17:26:13 +0100 Subject: [PATCH 95/97] Add return type --- modules/fontane/edited-text/prepcom.xqm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/prepcom.xqm b/modules/fontane/edited-text/prepcom.xqm index 154d9f9c..c42b2a6b 100644 --- a/modules/fontane/edited-text/prepcom.xqm +++ b/modules/fontane/edited-text/prepcom.xqm @@ -30,7 +30,8 @@ declare variable $prepCom:literature := : @param $id The notebook's ID, e.g. "16b00" : @return The current notebook with prepared editorial commentaries :) -declare function prepCom:main($tei as node()*, $id as xs:string) { +declare function prepCom:main($tei as node()*, $id as xs:string) +as element(tei:TEI){ let $add-ptr := prepCom:recursion($tei) let $prepared := prepCom:find-literature($add-ptr) let $store := xmldb:store($config:data-root || "/print/xml/", $id || "-prepcom.xml", $prepared) -- GitLab From a42f2a36cf175fbd69fcd115318e326c5c09b68c Mon Sep 17 00:00:00 2001 From: mrodzis Date: Thu, 28 Nov 2019 13:49:37 +0100 Subject: [PATCH 96/97] Improve tidying, fix bug in hi summary --- modules/fontane/edited-text/tidysimple.xqm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/fontane/edited-text/tidysimple.xqm b/modules/fontane/edited-text/tidysimple.xqm index 1a98008a..fe982709 100644 --- a/modules/fontane/edited-text/tidysimple.xqm +++ b/modules/fontane/edited-text/tidysimple.xqm @@ -831,7 +831,8 @@ declare function tidySimple:summarize-hi($nodes as node()*) as node()* { let $nodes-inbetween := $node/following::*[. << $next] return if($nodes-inbetween[self::tei:milestone[@unit = "paragraph"]] - or $next/ancestor::* = $node) then + or $next/ancestor::* = $node + or not(local-name($next) = "hi")) then tidySimple:copy-element($node, "summarize-hi") else element tei:hi { @@ -929,6 +930,13 @@ declare function tidySimple:tidy($nodes as node()*) as node()* { else () + case element(tei:list) return + if($node//text()[not(normalize-space(.) = "")]) then + tidySimple:copy-element($node, "tidy") + else + () + + default return tidySimple:copy-element($node, "tidy") }; -- GitLab From 13b600b86295d8caba8fc5dd9a792fe6cedb8475 Mon Sep 17 00:00:00 2001 From: mrodzis Date: Fri, 29 Nov 2019 15:32:30 +0100 Subject: [PATCH 97/97] Fix minor bugs --- modules/fontane/edited-text/simple2xhtml.xqm | 10 +++++----- modules/fontane/edited-text/sort.xqm | 2 +- modules/fontane/edited-text/tei2teisimple.xqm | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/fontane/edited-text/simple2xhtml.xqm b/modules/fontane/edited-text/simple2xhtml.xqm index 517f4757..78444415 100644 --- a/modules/fontane/edited-text/simple2xhtml.xqm +++ b/modules/fontane/edited-text/simple2xhtml.xqm @@ -14,6 +14,7 @@ declare namespace tei="http://www.tei-c.org/ns/1.0"; declare namespace xhtml="http://www.w3.org/1999/xhtml"; import module namespace config="http://textgrid.de/ns/SADE/config" at "../../config/config.xqm"; +import module namespace functx="http://www.functx.com"; declare function simple2xhtml:main($nodes as node()*, $uri as xs:string) { let $xhtml := element xhtml:div {simple2xhtml:recursion($nodes//tei:text)} @@ -968,7 +969,7 @@ as attribute() { : @author Michelle Weidling :) declare function simple2xhtml:make-integration($node as element(tei:seg)) { - let $bracket := $node//tei:ab[@function = ("integrate", "authorial_note")] + let $bracket := $node//tei:ab[@function = ("integrate", "authorial_note")][1] let $orientation := substring-after($bracket/@rend, "bracket_") (: @@ -1104,11 +1105,10 @@ declare function simple2xhtml:tidy($nodes as node()*) as node()* { : @param $node a tei:ptr or tei:note[@type = 'authorial'] : @return an icon as xhtml:i and a modal window as xhtml:div :) -declare function simple2xhtml:make-modal($node as node()) as element(*)* { +declare function simple2xhtml:make-modal($node) as element(*)* { let $content := - if($node/ancestor::tei:ab[@type = "sketch"]) then -(: $node/following-sibling::tei:figDesc/tei:ref//text()[not(ancestor::tei:index)]:) - $node/following-sibling::tei:figDesc//text()[not(ancestor::tei:index)] + if($node[ancestor::tei:ab[@type = "sketch"]]) then + $node/ancestor::tei:ab[@type = "sketch"]//tei:figDesc//text()[not(./ancestor::tei:index)] => string-join(" ") => simple2xhtml:fix-whitespaces() diff --git a/modules/fontane/edited-text/sort.xqm b/modules/fontane/edited-text/sort.xqm index 8305d84b..a5724bc8 100644 --- a/modules/fontane/edited-text/sort.xqm +++ b/modules/fontane/edited-text/sort.xqm @@ -315,7 +315,7 @@ as node()* { else if($node/@script) then let $prev-hs := $node/preceding::tei:handShift[1]/@script return - string-join(($node/@script, $prev-hs), " ") + attribute script {string-join(($node/@script, $prev-hs), " ")} else attribute script {$node/preceding::tei:handShift[@script][1]/@script} } diff --git a/modules/fontane/edited-text/tei2teisimple.xqm b/modules/fontane/edited-text/tei2teisimple.xqm index a6864142..fe223d1f 100644 --- a/modules/fontane/edited-text/tei2teisimple.xqm +++ b/modules/fontane/edited-text/tei2teisimple.xqm @@ -412,8 +412,8 @@ $log as xs:string) as node()* { if($node/@type = "highlighted" and simpleHelpers:is-hand-contemporary($node/@hand)) then $node - else if($node/following::node()[1][self::text()]) then - fontaneSimple:preserve-whitespace($node, $uri, $log) +(: else if($node/following::node()[1][self::text()]) then:) +(: fontaneSimple:preserve-whitespace($node, $uri, $log):) else fontaneSimple:transform($node/node(), $uri, $log) @@ -569,10 +569,10 @@ $log as xs:string) as node()* { || "cm; " || "margin-top:" || $node/@uly || "cm"} else (), - if($node/ancestor::tei:surface/@next) then + if($node/ancestor::tei:surface/@next and not($node/@xml:id)) then (attribute xml:id {$node/ancestor::tei:surface/@xml:id}, attribute next {$node/ancestor::tei:surface/@next}) - else if($node/ancestor::tei:surface/@prev) then + else if($node/ancestor::tei:surface/@prev and not($node/@xml:id)) then (attribute xml:id {$node/ancestor::tei:surface/@xml:id}, attribute prev {$node/ancestor::tei:surface/@prev}) else -- GitLab