Commit 23feff2a authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Add 3.22.20 red color and renaming of namespace

parent f14fe31a
......@@ -19,7 +19,7 @@ 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 console="http://exist-db.org/xquery/console";
import module namespace fontaneSimpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
import module namespace functx = "http://www.functx.com";
(:~
......@@ -68,19 +68,19 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
return
typeswitch ($node)
case text() return
fontaneSimpleHelpers:prepare-text($node)
simpleHelpers:prepare-text($node)
case element(tei:lb) return
if($node[@break = "keepHyphen"]) then
()
else
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:g) return
if($node[@ref = "#vds"]) then
()
else if($node/@ref ="#rth" or $node/@ref ="#hb") then
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
else
fontaneSimple:transform($node/node())
......@@ -111,14 +111,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:add) return
if($node/@type = "edited_text"
or $node/child::tei:seg[@type = "multiphrase"]) then
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
else if($node/@cause ="catchword" or $node/@cause ="unclear") then
()
else if($node/@rend ="|") then
fontaneSimple:transform($node/node())
else if(not($node/@xml:id)) then
fontaneSimple:transform($node/node())
else if(fontaneSimpleHelpers:is-transposed($node)) then
else if(simpleHelpers:is-transposed($node)) then
let $corresp := //tei:metamark[matches(@target, $node/@xml:id)]
return
(fontaneSimple:transform($corresp/node()),
......@@ -128,7 +128,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:addSpan) return
if($node/@type = "edited_text") then
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
else
()
......@@ -139,11 +139,13 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
if(count($node/*) = 1 and $node/child::tei:fw) then
()
else if($node/@type = "heading") then
fontaneSimpleHelpers:make-head($node)
simpleHelpers:make-head($node)
else if(matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman")) then
fontaneSimpleHelpers:make-seg-with-rendition($node)
else if((simpleHelpers:has-valid-style($node)
or matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman"))
and simpleHelpers:has-valid-text($node)) then
simpleHelpers:make-seg-with-rendition($node)
else if(not($node/@type = "item")) then
fontaneSimple:transform($node/node())
......@@ -152,23 +154,23 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
fontaneSimple:transform($node/node())
}
else if($node/@type = "item"
and fontaneSimpleHelpers:is-transposed($node)) then
and simpleHelpers:is-transposed($node)) then
()
else
fontaneSimple:transform($node/node())
case element(tei:handShift) return
if($node/@new) then
if(fontaneSimpleHelpers:is-hand-valid($node)
and not(fontaneSimpleHelpers:is-prev-valid-hand-same($node))) then
fontaneSimpleHelpers:copy-element($node)
if(simpleHelpers:is-hand-valid($node)
and not(simpleHelpers:is-prev-valid-hand-same($node))) then
simpleHelpers:copy-element($node)
else
()
else
(: tei:fontaneSimpleHelpers:copy-element($node)ft without @new denote the duct
(: tei:simpleHelpers:copy-element($node)ft without @new denote the duct
of the current writer or a change of writing medium :)
if(fontaneSimpleHelpers:is-hand-valid($node/preceding::tei:handShift[@new][1])) then
fontaneSimpleHelpers:copy-element($node)
if(simpleHelpers:is-hand-valid($node/preceding::tei:handShift[@new][1])) then
simpleHelpers:copy-element($node)
else
()
......@@ -182,23 +184,22 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
()
else if($node/@type = "heading") then
fontaneSimpleHelpers:make-head($node)
simpleHelpers:make-head($node)
else if(matches($node/@style, "underline")
and not(matches($node/@style, "vertical-align"))) then
fontaneSimple:transform($node/node())
else if($node/@style and fontaneSimpleHelpers:has-valid-text($node)) then
element{QName("http://www.tei-c.org/ns/1.0", $node/name())}{
attribute rendition {fontaneSimpleHelpers:filter-rendition($node/@style)},
$node/(@* except @style),
fontaneSimple:transform($node/node())
}
else if((simpleHelpers:has-valid-style($node)
or matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman"))
and simpleHelpers:has-valid-text($node)) then
simpleHelpers:make-seg-with-rendition($node)
else if($node/@type = "initials" or $node/@type = "monogram"
or $node/@type = "multiphrase")
then
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
else if($node/@type = "auction_number"
or $node/@type = "cancel"
......@@ -207,48 +208,44 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
then
()
else if(matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman")) then
fontaneSimpleHelpers:make-seg-with-rendition($node)
else
fontaneSimple:transform($node/node())
case element(tei:hi) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
(: TODO if $node/@type = "highlighted" then make
a hi[@type = "vertical-mark"] in the second stage of creating the
simple format. use fontaneSimpleHelpers:get-xml-chunk($node) for this.:)
simple format. use simpleHelpers:get-xml-chunk($node) for this.:)
case element(tei:mod) return
if($node/@type = "highlighted"
and fontaneSimpleHelpers:is-hand-contemporary($node/@hand)) then
fontaneSimpleHelpers:copy-element($node)
and simpleHelpers:is-hand-contemporary($node/@hand)) then
simpleHelpers:copy-element($node)
else
fontaneSimple:transform($node/node())
case element(tei:anchor) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:surface) return
if(matches($node/@n, "cover")) then
fontaneSimpleHelpers:make-pb-with-type($node/@n)
else if(fontaneSimpleHelpers:is-page($node)
simpleHelpers:make-pb-with-type($node/@n)
else if(simpleHelpers:is-page($node)
and $node/@type = "clipping") then
(fontaneSimpleHelpers:make-pb($node),
(simpleHelpers:make-pb($node),
(if(not($node/@subtype = "Kalenderblatt"
or $node/@subtype = "Zeitungsausschnitt_Fragment")) then
fontaneSimple:transform($node/node())
else
()))
else if(fontaneSimpleHelpers:is-page($node)) then
(fontaneSimpleHelpers:make-pb($node),
else if(simpleHelpers:is-page($node)) then
(simpleHelpers:make-pb($node),
fontaneSimple:transform($node/node()))
else if($node/@type = "label" and
(contains($node/@subtype, "Fontane")
or contains($node/@subtype, "Hersteller"))
) then
fontaneSimpleHelpers:make-div($node)
simpleHelpers:make-div($node)
else
()
......@@ -256,14 +253,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
if($node/@unit = "illustration") then
()
(: else if($node/@unit = "section") then:)
(: fontaneSimpleHelpers:make-section($node):)
(: simpleHelpers:make-section($node):)
(: else if($node/@unit = "pararaph") then:)
(: fontaneSimple:make-paragraph($node):)
else
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:gap) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:metamark) return
if($node/@function = "integrate"
......@@ -350,7 +347,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
}
else if($node/@type = "heading") then
fontaneSimpleHelpers:make-head($node)
simpleHelpers:make-head($node)
else if($node/@type = "list" or $node/@type = "item") then
element {QName("http://www.tei-c.org/ns/1.0", $node/@type)}{
......@@ -360,18 +357,25 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else if($node/@type = "legend") then
element {QName("http://www.tei-c.org/ns/1.0", "div")}{
$node/@*,
(if($node/@style
or $node/@rendition) then
attribute rendition {simpleHelpers:filter-rendition($node)}
else
()),
$node/(@* except (@rendition, @style)),
fontaneSimple:transform($node/node())
}
else if(matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman")) then
fontaneSimpleHelpers:make-seg-with-rendition($node)
else if((simpleHelpers:has-valid-style($node)
or matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman"))
and simpleHelpers:has-valid-text($node)) then
simpleHelpers:make-seg-with-rendition($node)
else if(not($node/@xml:id)) then
fontaneSimple:transform($node/node())
else if($node/@xml:id and fontaneSimpleHelpers:is-transposed($node)) then
else if($node/@xml:id and simpleHelpers:is-transposed($node)) then
()
else
......@@ -422,14 +426,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else
()
else
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:note) return
if($node/@type = "authorial"
and not($node/@subtype = "footnote")) then
()
else
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:certainty) return
element {QName("http://www.tei-c.org/ns/1.0", "note")}{
......@@ -441,25 +445,25 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
}
case element(tei:figDesc) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:ref) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:space) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:choice) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:abbr) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:expan) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:rs) return
fontaneSimpleHelpers:copy-element($node)
simpleHelpers:copy-element($node)
case element(tei:date) return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
......@@ -482,7 +486,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:ptr) return
let $target-id := substring-after($node/@target, "#")
let $target := $node/ancestor::tei:TEI//*[matches(@xml:id, $target-id)]
let $stripped-target := fontaneSimpleHelpers:strip-element($target)
let $stripped-target := simpleHelpers:strip-element($target)
return fontaneSimple:transform($stripped-target)
default return
......
......@@ -450,10 +450,13 @@ declare
%test:name("Topography of the page")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" rotate=""270"" uly=""16"" style=""border-bottom-style:solid; border-right-style:solid; padding-bottom:0.5cm; padding-right:0.5cm""><line style=""margin-left:0cm""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/> 4. Iron and Steel.</line></zone>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>", " 4. Iron and Steel.")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" rotate=""326""><line style=""margin-left:0.0cm""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>werfen </line></zone>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>", "werfen ")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><zone xmlns=""http://www.tei-c.org/ns/1.0"" style=""font-size:x-large"" ulx=""2.1"" uly=""13.8"" lrx=""2.9"" lry=""15.0""><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.0cm""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>(</line></zone></zone>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>", "(")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large"" ulx=""2.1"" uly=""13.8"" lrx=""2.9"" lry=""15.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>(</seg>")
function teisimple-test:analyze-topography($node as element(*)) {
fontaneSimple:transform($node)
};
......@@ -875,16 +878,16 @@ declare
declare
%test:name("print typography")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""#black_letter""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</line>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""print-black-letter""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""black_letter""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""#roman""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</line>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""print-antiqua""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""roman""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""#black_letter""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""print-black-letter""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""black_letter""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""#roman""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</zone>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""print-antiqua""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""roman""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Dampf - Schiffahrt</seg>")
function teisimple-test:analyze-print-typography($node as element(*)) {
fontaneSimple:transform($node)
......@@ -982,7 +985,7 @@ declare
declare
%test:name("Small caps")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:2.0cm"" rendition=""#roman #smallcaps""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Stadtrichter Lehfeldt.</line>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""print-antiqua smallcaps""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Stadtrichter Lehfeldt.</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""roman smallcaps""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Stadtrichter Lehfeldt.</seg>")
function teisimple-test:analyze-print-small-caps($node as element(*)) {
fontaneSimple:transform($node)
......@@ -1011,6 +1014,20 @@ declare
};
(: 3.22.18 Print: red letters :)
declare
%test:name("Print: red letters")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" style=""color:red""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>23</seg></line>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""color:red""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>23</seg>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0"" type=""legend"" style=""color:red"" rendition=""#roman"" ulx=""0.8"" uly=""12.5""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.5cm"">Wahre Abbildung des wunderthätigen</line></zone>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""legend"" rendition=""color:red roman"" ulx=""0.8"" uly=""12.5""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Wahre Abbildung des wunderthätigen</div>")
function teisimple-test:analyze-print-red($node as element(*)) {
fontaneSimple:transform($node)
};
(: SECTIONS :)
declare
......
xquery version "3.1";
module namespace fontaneSimpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers";
module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers";
declare namespace tei="http://www.tei-c.org/ns/1.0";
......@@ -22,7 +22,7 @@ import module namespace functx = "http://www.functx.com";
: @param $hand the tei:handShift/@new or tei:mod/@hand to be checked
: @return xs:boolean
: :)
declare function fontaneSimpleHelpers:is-hand-contemporary($hand as xs:string?)
declare function simpleHelpers:is-hand-contemporary($hand as xs:string?)
as xs:boolean {
let $hand := replace($hand, "#", "")
let $file := doc("/db/sade-projects/textgrid/data/xml/data/16b00.xml")
......@@ -37,7 +37,7 @@ as xs:boolean {
declare function fontaneSimpleHelpers:is-transposed($node as node())
declare function simpleHelpers:is-transposed($node as node())
as xs:boolean {
let $root := $node/ancestor::tei:TEI
return
......@@ -48,7 +48,7 @@ as xs:boolean {
};
declare function fontaneSimpleHelpers:strip-element($node as node()) {
declare function simpleHelpers:strip-element($node as node()) {
element {$node/name()} {
$node/@type,
fontaneSimple:transform($node/node())
......@@ -68,13 +68,13 @@ declare function fontaneSimpleHelpers:strip-element($node as node()) {
: @param $node the current text node
: @return text() the formatted text
: :)
declare function fontaneSimpleHelpers:prepare-text($node as text()) as text()? {
if(fontaneSimpleHelpers:is-valid-text($node)
declare function simpleHelpers:prepare-text($node as text()) as text()? {
if(simpleHelpers:is-valid-text($node)
and not(normalize-space($node) = "")) then
let $cleared-hyphen :=
if(ends-with($node, "-") and not(fontaneSimpleHelpers:keep-hyphen($node))) then
if(ends-with($node, "-") and not(simpleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "-")}
else if(ends-with($node, "⸗") and not(fontaneSimpleHelpers:keep-hyphen($node))) then
else if(ends-with($node, "⸗") and not(simpleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "⸗")}
else
$node
......@@ -102,7 +102,7 @@ declare function fontaneSimpleHelpers:prepare-text($node as text()) as text()? {
: @param $node the current text node
: @return xs:boolean
: :)
declare function fontaneSimpleHelpers:keep-hyphen($node as text()) as xs:boolean {
declare function simpleHelpers:keep-hyphen($node as text()) as xs:boolean {
if($node/parent::tei:line/following-sibling::*[1][self::tei:lb[@break = "keepHyphen"]])
then
true()
......@@ -117,7 +117,7 @@ declare function fontaneSimpleHelpers:keep-hyphen($node as text()) as xs:boolean
: @param $node the current text node
: @return node() a copy of the current node
: :)
declare function fontaneSimpleHelpers:copy-element($node as node()) as node() {
declare function simpleHelpers:copy-element($node as node()) as node() {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())}{
$node/@*,
fontaneSimple:transform($node/node())
......@@ -125,12 +125,12 @@ declare function fontaneSimpleHelpers:copy-element($node as node()) as node() {
};
declare function fontaneSimpleHelpers:has-valid-text($node as node()) as xs:boolean {
declare function simpleHelpers:has-valid-text($node as node()) as xs:boolean {
let $text-nodes := $node/descendant::text()[not(normalize-space(.) = "")]
let $results :=
for $text-node in $text-nodes
return
fontaneSimpleHelpers:is-valid-text($text-node)
simpleHelpers:is-valid-text($text-node)
return
if(functx:is-value-in-sequence(true(), $results)) then
true()
......@@ -139,10 +139,10 @@ declare function fontaneSimpleHelpers:has-valid-text($node as node()) as xs:bool
};
declare function fontaneSimpleHelpers:is-valid-text($node as text()) as xs:boolean {
declare function simpleHelpers:is-valid-text($node as text()) as xs:boolean {
let $current-hand := $node/preceding::tei:handShift[@new][1]/@new
return
if(fontaneSimpleHelpers:is-hand-contemporary($current-hand)
if(simpleHelpers:is-hand-contemporary($current-hand)
or ($node[ancestor::tei:surface[@type = "label"]]
and matches($current-hand, "Friedrich_Fontane"))
or $node/ancestor::*[@type = "edited_text"]
......@@ -153,7 +153,7 @@ declare function fontaneSimpleHelpers:is-valid-text($node as text()) as xs:boole
};
declare function fontaneSimpleHelpers:is-page($node as node()) as xs:boolean {
declare function simpleHelpers:is-page($node as node()) as xs:boolean {
matches($node/@n, "[0-9IVXMCD]{1,7}[rv]{1}")
};
......@@ -164,14 +164,14 @@ declare function fontaneSimpleHelpers:is-page($node as node()) as xs:boolean {
: @param $node the current tei:surface node
: @return element(tei:pb)
: :)
declare function fontaneSimpleHelpers:make-pb($node as node()) as element(tei:pb) {
declare function simpleHelpers:make-pb($node as node()) as element(tei:pb) {
element {QName("http://www.tei-c.org/ns/1.0", "pb")}{
$node/@n
}
};
declare function fontaneSimpleHelpers:make-pb-with-type($type as xs:string) as element(tei:pb) {
declare function simpleHelpers:make-pb-with-type($type as xs:string) as element(tei:pb) {
element {QName("http://www.tei-c.org/ns/1.0", "pb")}{
attribute type {$type}
}
......@@ -185,10 +185,10 @@ declare function fontaneSimpleHelpers:make-pb-with-type($type as xs:string) as e
: @param $node the current tei:line, tei:zone or tei:seg node
: @return element(tei:head)
: :)
declare function fontaneSimpleHelpers:make-head($node as node()) as element(tei:head) {
declare function simpleHelpers:make-head($node as node()) as element(tei:head) {
element tei:head {
(if($node/descendant::tei:seg[matches(@style, "font-size")]) then
attribute type {fontaneSimpleHelpers:get-font-size($node)}
attribute type {simpleHelpers:get-font-size($node)}
else
attribute type {"default"}
),
......@@ -209,8 +209,8 @@ declare function fontaneSimpleHelpers:make-head($node as node()) as element(tei:
: @param $node the current tei:surface node
: @return element(tei:div)
: :)
declare function fontaneSimpleHelpers:make-div($node as node()) as element(tei:div)? {
if(fontaneSimpleHelpers:has-valid-text($node)) then
declare function simpleHelpers:make-div($node as node()) as element(tei:div)? {
if(simpleHelpers:has-valid-text($node)) then
element tei:div{
$node/(@* except (@facs, @n, @attachment, @subtype, @ulx, @uly, @lrx, @lry, @points)),
fontaneSimple:transform($node/node())
......@@ -220,9 +220,9 @@ declare function fontaneSimpleHelpers:make-div($node as node()) as element(tei:d
};
declare function fontaneSimpleHelpers:make-div-with-type($node as node(), $type as xs:string)
declare function simpleHelpers:make-div-with-type($node as node(), $type as xs:string)
as element(tei:div)? {
if(fontaneSimpleHelpers:has-valid-text($node)) then
if(simpleHelpers:has-valid-text($node)) then
element tei:div{
attribute type {$type},
$node/(@* except (@facs, @n, @attachment, @subtype, @ulx, @uly, @lrx, @lry, @points)),
......@@ -240,15 +240,33 @@ as element(tei:div)? {
: @param $node the current tei:line, tei:zone or tei:seg node with @type = heading
: @return xs:string the font size value
: :)
declare function fontaneSimpleHelpers:get-font-size($node as node()) as xs:string {
declare function simpleHelpers:get-font-size($node as node()) as xs:string {
(: example for style: "font-size:large; letter-spacing:0.2cm; text-decoration:underline" :)
let $tmp := substring-after($node/descendant-or-self::tei:seg[matches(@style, "font-size")]/@style, "font-size:")
return substring-before($tmp, ";")
};
declare function fontaneSimpleHelpers:filter-rendition($seg-styles as xs:string) as xs:string* {
let $styles := tokenize($seg-styles, " ")
declare function simpleHelpers:has-valid-style($node as node())
as xs:boolean {
let $style := $node/@style
return
if(matches($style, "font")
or matches($style, "align")
or matches($style, "spacing")
or matches($style, "uppercase")
or matches($style, "color:red")
or matches($style, "black_letter")
or matches($style, "roman")
or matches($style, "line-through")) then
true()
else
false()
};
declare function simpleHelpers:filter-rendition($node as node()) as xs:string* {
let $styles := tokenize($node/@style, " ")
let $relevant-styles :=
for $style in $styles
return
......@@ -256,17 +274,33 @@ declare function fontaneSimpleHelpers:filter-rendition($seg-styles as xs:string)
or matches($style, "align")
or matches($style, "spacing")
or matches($style, "uppercase")
or matches($style, "color:red")
or matches($style, "black_letter")
or matches($style, "roman")
or matches($style, "line-through")) then
$style
else
()
return string-join($relevant-styles, " ")
let $transformed-renditions :=
for $rend in tokenize($node/@rendition, " ")
return
if(matches($rend, "black_letter")) then
"black_letter"
else if(matches($rend, "roman")) then
"roman"
else
if(matches($rend, "#")) then
substring-after($rend, "#")
else
$rend
let $new-renditions := ($relevant-styles, $transformed-renditions)
return string-join($new-renditions, " ")
};
declare function fontaneSimpleHelpers:is-hand-valid($node as element(tei:handShift))
declare function simpleHelpers:is-hand-valid($node as element(tei:handShift))
as xs:boolean {
if(fontaneSimpleHelpers:is-hand-contemporary($node/@new)
if(simpleHelpers:is-hand-contemporary($node/@new)
or ($node/ancestor::tei:surface[@type = "label"]
and matches($node/@new, "Friedrich_Fontane"))
) then
......@@ -276,9 +310,9 @@ as xs:boolean {
};
declare function fontaneSimpleHelpers:is-prev-valid-hand-same($node as element(tei:handShift))
declare function simpleHelpers:is-prev-valid-hand-same($node as element(tei:handShift))
as xs:boolean {
let $prev-valid := $node/preceding::tei:handShift[fontaneSimpleHelpers:is-hand-valid(.)][1]
let $prev-valid := $node/preceding::tei:handShift[simpleHelpers:is-hand-valid(.)][1]
return
if($prev-valid
and functx:sequence-deep-equal($node/@*, $prev-valid/@*)) then
......@@ -289,7 +323,7 @@ as xs:boolean {
(: TODO :)
declare function fontaneSimpleHelpers:make-section($node as element(tei:milestone))
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]
......@@ -299,32 +333,17 @@ as element(tei:section) {
};
declare function fontaneSimpleHelpers:make-seg-with-rendition($node as element(*))
declare function simpleHelpers:make-seg-with-rendition($node as element(*))
as element(tei:seg) {
let $renditions := $node/@rendition
let $transform-rendition :=
for $rend in tokenize($renditions, " ")
return
if(matches($rend, "black_letter")) then
"print-black-letter"
else if(matches($rend, "roman")) then
"print-antiqua"
else
if(matches($rend, "#")) then
substring-after($rend, "#")
else
$rend
let $new-rendition := string-join($transform-rendition, " ")
return
element tei:seg {
$node/(@* except (@rendition, @style)),
attribute rendition {$new-rendition},
fontaneSimple:transform($node/node())