Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
fontane-notizbuecher
SADE
Commits
23feff2a
Commit
23feff2a
authored
Jun 29, 2018
by
MRodz
Committed by
mrodzis
Feb 05, 2019
Browse files
Add 3.22.20 red color and renaming of namespace
parent
f14fe31a
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
modules/fontane/tei2teisimple.xqm
View file @
23feff2a
...
...
@@ -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
fontaneS
impleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
import module namespace
s
impleHelpers="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
fontaneS
impleHelpers:prepare-text($node)
s
impleHelpers:prepare-text($node)
case element(tei:lb) return
if($node[@break = "keepHyphen"]) then
()
else
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:g) return
if($node[@ref = "#vds"]) then
()
else if($node/@ref ="#rth" or $node/@ref ="#hb") then
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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(
fontaneS
impleHelpers:is-transposed($node)) then
else if(
s
impleHelpers: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
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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
fontaneS
impleHelpers:make-head($node)
s
impleHelpers: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
fontaneS
impleHelpers:is-transposed($node)) then
and
s
impleHelpers:is-transposed($node)) then
()
else
fontaneSimple:transform($node/node())
case element(tei:handShift) return
if($node/@new) then
if(
fontaneS
impleHelpers:is-hand-valid($node)
and not(
fontaneS
impleHelpers:is-prev-valid-hand-same($node))) then
fontaneS
impleHelpers:copy-element($node)
if(
s
impleHelpers:is-hand-valid($node)
and not(
s
impleHelpers:is-prev-valid-hand-same($node))) then
s
impleHelpers:copy-element($node)
else
()
else
(: tei:
fontaneS
impleHelpers:copy-element($node)ft without @new denote the duct
(: tei:
s
impleHelpers:copy-element($node)ft without @new denote the duct
of the current writer or a change of writing medium :)
if(
fontaneS
impleHelpers:is-hand-valid($node/preceding::tei:handShift[@new][1])) then
fontaneS
impleHelpers:copy-element($node)
if(
s
impleHelpers:is-hand-valid($node/preceding::tei:handShift[@new][1])) then
s
impleHelpers:copy-element($node)
else
()
...
...
@@ -182,23 +184,22 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
()
else if($node/@type = "heading") then
fontaneS
impleHelpers:make-head($node)
s
impleHelpers: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
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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
fontaneS
impleHelpers:get-xml-chunk($node) for this.:)
simple format. use
s
impleHelpers:get-xml-chunk($node) for this.:)
case element(tei:mod) return
if($node/@type = "highlighted"
and
fontaneS
impleHelpers:is-hand-contemporary($node/@hand)) then
fontaneS
impleHelpers:copy-element($node)
and
s
impleHelpers:is-hand-contemporary($node/@hand)) then
s
impleHelpers:copy-element($node)
else
fontaneSimple:transform($node/node())
case element(tei:anchor) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:surface) return
if(matches($node/@n, "cover")) then
fontaneS
impleHelpers:make-pb-with-type($node/@n)
else if(
fontaneS
impleHelpers:is-page($node)
s
impleHelpers:make-pb-with-type($node/@n)
else if(
s
impleHelpers:is-page($node)
and $node/@type = "clipping") then
(
fontaneS
impleHelpers:make-pb($node),
(
s
impleHelpers:make-pb($node),
(if(not($node/@subtype = "Kalenderblatt"
or $node/@subtype = "Zeitungsausschnitt_Fragment")) then
fontaneSimple:transform($node/node())
else
()))
else if(
fontaneS
impleHelpers:is-page($node)) then
(
fontaneS
impleHelpers:make-pb($node),
else if(
s
impleHelpers:is-page($node)) then
(
s
impleHelpers:make-pb($node),
fontaneSimple:transform($node/node()))
else if($node/@type = "label" and
(contains($node/@subtype, "Fontane")
or contains($node/@subtype, "Hersteller"))
) then
fontaneS
impleHelpers:make-div($node)
s
impleHelpers: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:)
(:
fontaneS
impleHelpers:make-section($node):)
(:
s
impleHelpers:make-section($node):)
(: else if($node/@unit = "pararaph") then:)
(: fontaneSimple:make-paragraph($node):)
else
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:gap) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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
fontaneS
impleHelpers:make-head($node)
s
impleHelpers: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
fontaneS
impleHelpers:is-transposed($node)) then
else if($node/@xml:id and
s
impleHelpers:is-transposed($node)) then
()
else
...
...
@@ -422,14 +426,14 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else
()
else
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:note) return
if($node/@type = "authorial"
and not($node/@subtype = "footnote")) then
()
else
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:ref) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:space) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:choice) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:abbr) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:expan) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers:copy-element($node)
case element(tei:rs) return
fontaneS
impleHelpers:copy-element($node)
s
impleHelpers: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 :=
fontaneS
impleHelpers:strip-element($target)
let $stripped-target :=
s
impleHelpers:strip-element($target)
return fontaneSimple:transform($stripped-target)
default return
...
...
modules/fontane/teisimple-test.xql
View file @
23feff2a
...
...
@@ -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
...
...
modules/fontane/teisimplehelpers.xqm
View file @
23feff2a
xquery version "3.1";
module namespace
fontaneS
impleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers";
module namespace
s
impleHelpers="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
fontaneS
impleHelpers:is-hand-contemporary($hand as xs:string?)
declare function
s
impleHelpers: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
fontaneS
impleHelpers:is-transposed($node as node())
declare function
s
impleHelpers:is-transposed($node as node())
as xs:boolean {
let $root := $node/ancestor::tei:TEI
return
...
...
@@ -48,7 +48,7 @@ as xs:boolean {
};
declare function
fontaneS
impleHelpers:strip-element($node as node()) {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:prepare-text($node as text()) as text()? {
if(
fontaneS
impleHelpers:is-valid-text($node)
declare function
s
impleHelpers:prepare-text($node as text()) as text()? {
if(
s
impleHelpers:is-valid-text($node)
and not(normalize-space($node) = "")) then
let $cleared-hyphen :=
if(ends-with($node, "-") and not(
fontaneS
impleHelpers:keep-hyphen($node))) then
if(ends-with($node, "-") and not(
s
impleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "-")}
else if(ends-with($node, "⸗") and not(
fontaneS
impleHelpers:keep-hyphen($node))) then
else if(ends-with($node, "⸗") and not(
s
impleHelpers: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
fontaneS
impleHelpers:keep-hyphen($node as text()) as xs:boolean {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:copy-element($node as node()) as node() {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:has-valid-text($node as node()) as xs:boolean {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:is-valid-text($text-node)
s
impleHelpers: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
fontaneS
impleHelpers:is-valid-text($node as text()) as xs:boolean {
declare function
s
impleHelpers:is-valid-text($node as text()) as xs:boolean {
let $current-hand := $node/preceding::tei:handShift[@new][1]/@new
return
if(
fontaneS
impleHelpers:is-hand-contemporary($current-hand)
if(
s
impleHelpers: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
fontaneS
impleHelpers:is-page($node as node()) as xs:boolean {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:make-pb($node as node()) as element(tei:pb) {
declare function
s
impleHelpers:make-pb($node as node()) as element(tei:pb) {
element {QName("http://www.tei-c.org/ns/1.0", "pb")}{
$node/@n
}
};
declare function
fontaneS
impleHelpers:make-pb-with-type($type as xs:string) as element(tei:pb) {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:make-head($node as node()) as element(tei:head) {
declare function
s
impleHelpers:make-head($node as node()) as element(tei:head) {
element tei:head {
(if($node/descendant::tei:seg[matches(@style, "font-size")]) then
attribute type {
fontaneS
impleHelpers:get-font-size($node)}
attribute type {
s
impleHelpers: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
fontaneS
impleHelpers:make-div($node as node()) as element(tei:div)? {
if(
fontaneS
impleHelpers:has-valid-text($node)) then
declare function
s
impleHelpers:make-div($node as node()) as element(tei:div)? {
if(
s
impleHelpers: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
fontaneS
impleHelpers:make-div-with-type($node as node(), $type as xs:string)
declare function
s
impleHelpers:make-div-with-type($node as node(), $type as xs:string)
as element(tei:div)? {
if(
fontaneS
impleHelpers:has-valid-text($node)) then
if(
s
impleHelpers: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
fontaneS
impleHelpers:get-font-size($node as node()) as xs:string {
declare function
s
impleHelpers: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
fontaneS
impleHelpers:is-hand-valid($node as element(tei:handShift))
declare function
s
impleHelpers:is-hand-valid($node as element(tei:handShift))
as xs:boolean {
if(
fontaneS
impleHelpers:is-hand-contemporary($node/@new)
if(
s
impleHelpers: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
fontaneS
impleHelpers:is-prev-valid-hand-same($node as element(tei:handShift))
declare function
s
impleHelpers:is-prev-valid-hand-same($node as element(tei:handShift))
as xs:boolean {
let $prev-valid := $node/preceding::tei:handShift[
fontaneS
impleHelpers:is-hand-valid(.)][1]
let $prev-valid := $node/preceding::tei:handShift[
s
impleHelpers: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
fontaneS
impleHelpers:make-section($node as element(tei:milestone))
declare function
s
impleHelpers: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
fontaneS
impleHelpers:make-seg-with-rendition($node as element(*))
declare function
s
impleHelpers: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())