Commit 88009aa2 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Tidy up elements (only apply valid elements)

parent b9079444
......@@ -354,6 +354,8 @@ declare function simpleHelpers:filter-rendition($node as node()) as xs:string* {
:
: TODO check if we reach calendar pages
: @author Michelle Rodzis
: @param $hands a string sequence containing all contemporary hands that are
: declared in tei:handNotes
: @param $node the current tei:handShift element
: @return xs:boolean
:)
......@@ -370,6 +372,27 @@ $node as element(tei:handShift)) as xs:boolean {
false()
};
declare function simpleHelpers:belongs-to-valid-hand($hands as xs:string*,
$node as element(*)*) as xs:boolean {
(: in some cases elements like tei:front or tei:body don't have a preceeding
tei:handShift because the initial pages are empty. in these cases we want to
preserve the element and therefore set a valid tei:handShift :)
let $prev-hand :=
if($node/preceding::tei:handShift[1]) then
$node/preceding::tei:handShift[1]
else
<tei:handShift new="#Fontane"/>
return
if(simpleHelpers:is-hand-valid($hands, $prev-hand)) then
true()
else
false()
};
(:~
: Checks if the previous valid handShift is the same as the current handShift.
: This does not only encompass the writer but also the script type and ductus.
......
......@@ -21,4 +21,18 @@ declare
function tidysimple-test:handShift($node as element(*)) {
tidySimple:tidy($node)
};
(: only apply valid elements, i.e. elements that belong to a valid hand :)
declare
%test:name("only apply valid elements")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Friedrich_Fontane"" medium=""black_ink"" script=""Latn clean""/><tei:seg xmlns:tei=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</tei:seg></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""/>")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><tei:handShift xmlns:tei=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/><tei:head xmlns:tei=""http://www.tei-c.org/ns/1.0"" type=""x-large""><rs xmlns:tei=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther"">Luther</rs></tei:head></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><tei:handShift xmlns:tei=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/><tei:head xmlns:tei=""http://www.tei-c.org/ns/1.0"" type=""x-large""><rs xmlns:tei=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther"">Luther</rs></tei:head></body>")
function tidysimple-test:valid-elements($node as element(*)) {
tidySimple:tidy($node)
};
\ No newline at end of file
......@@ -24,7 +24,7 @@ import module namespace functx = "http://www.functx.com";
import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelpers" at "teisimplehelpers.xqm";
declare variable $tidySimple:valid-hand :=
declare variable $tidySimple:valid-hands :=
for $res in collection("/db/sade-projects/textgrid/data/xml/data")
return
$res//tei:handNote[@script = "contemporary"]/@xml:id/string();
......@@ -52,15 +52,17 @@ declare function tidySimple:main() {
declare function tidySimple:tidy($nodes as node()*) as node()* {
for $node in $nodes return
(console:log($node),
typeswitch ($node)
case text() return
$node
case element(tei:handShift) return
if(simpleHelpers:is-hand-valid($tidySimple:valid-hand, $node)) then
if(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node)) then
simpleHelpers:copy-second-stage-element($node)
else
()
default return
simpleHelpers:copy-second-stage-element($node))
if(simpleHelpers:belongs-to-valid-hand($tidySimple:valid-hands, $node)) then
simpleHelpers:copy-second-stage-element($node)
else
()
};
\ No newline at end of file
......@@ -532,8 +532,7 @@
<pb type="inner_front_cover"/>
</front>
<body>
<pb n="1r"/>
<tei:seg xmlns:tei="http://www.tei-c.org/ns/1.0" rendition="font-size:small">Dieses Buch hat 52 Blatt.</tei:seg><handShift new="#Fontane" script="Latf standard"/>
<pb n="1r"/><handShift new="#Fontane" script="Latf standard"/>
<handShift new="#Fontane"/>
<handShift new="#Fontane"/>
<milestone unit="section" type="Text_1" spanTo="#C07_3r_s"/>
......@@ -655,7 +654,6 @@
<handShift new="#Fontane"/>
<pb n="3v"/>
<pb n="4r"/>
<milestone unit="section" type="Text_2" spanTo="#C07_4r_s"/>
<handShift new="#Fontane" script="Latn clean"/>
<tei:head xmlns:tei="http://www.tei-c.org/ns/1.0" type="x-large">
<tei:seg rendition="font-size:x-large; letter-spacing:0.2cm">
......@@ -670,7 +668,6 @@
<handShift new="#Fontane"/>
<pb n="5v"/>
<pb n="6r"/>
<milestone unit="section" type="Text_3" spanTo="#C07_15r_s"/>
<handShift new="#Fontane" script="Latn clean"/>
<tei:head xmlns:tei="http://www.tei-c.org/ns/1.0" type="large">
<hi>
......@@ -715,20 +712,7 @@
</rs>, nach gehäufter Unthat, unterlagen in der dreitägigen<rs type="direct" ref="eve:Schlacht_Unstrut">Schlacht an der <hi>Unstrut</hi>
</rs>(bei <rs type="direct" ref="plc:Frankenhausen">Frankenhausen</rs>) gegendie <rs type="direct" ref="psn:Franken_Volk">Franken</rs> und <rs type="direct" ref="psn:Sachsen_Volk">Sachsen</rs>,die sich nun in <rs type="indirect" ref="plc:Thueringen">das Land</rs>theilten. Dies war<date when="0528" type="asynchronous">528</date>.<tei:handShift xmlns:tei="http://www.tei-c.org/ns/1.0" new="#Fontane" script="standard"/>
<pb n="7v"/>
<pb n="8r"/>
<tei:head xmlns:tei="http://www.tei-c.org/ns/1.0" type="default" subtype="section">
<handShift new="#Fontane" script="clean"/>II. <hi>
<rs type="direct" ref="plc:Thueringen">Thüringen</rs> unter</hi>
<rs type="direct" ref="org:fraenkische_Herrschaft">
<hi xml:id="C07_8r_g" prev="#C07_8r_f">fränkischer Herrschaft</hi>
</rs>und unter den <rs xml:id="C07_8r_a" next="#C07_8r_b" type="direct" ref="psn:deutsche_Kaiser">
<hi xml:id="C07_8r_h" next="#C07_8r_i">deutschen</hi>
</rs>
<rs xml:id="C07_8r_b" prev="#C07_8r_a" type="direct" ref="psn:deutsche_Kaiser">
<hi xml:id="C07_8r_i" prev="#C07_8r_h">Kaisern</hi>
</rs> (<rs type="direct" ref="psn:Franken_Volk">Franken</rs>, <rs type="direct" ref="psn:Sachsen_Volk">Sachsen</rs>und wieder <rs type="direct" ref="psn:Franken_Volk">Franken</rs> oder<rs type="direct" ref="psn:Salier">Saliern</rs>)<lb type="edited_text"/>
<date from="0528" to="1125" type="asynchronous">von 528 – 1125</date>
</tei:head>All diese Zeit über hat<rs type="direct" ref="plc:Thueringen">Thüringen</rs>abwechselnd<hi>Grafen</hi>, <hi>Richter</hi>,<hi>Herzzöge</hi>, <hi>Markgrafen</hi>,die von den Kaisern eingesetzt werden und malfreier, mal abhängiger<rs type="indirect" ref="plc:Thueringen">das Land</rs> regiren.<tei:head xmlns:tei="http://www.tei-c.org/ns/1.0" type="default" subtype="section">III. <rs type="direct" ref="plc:Thueringen">
<pb n="8r"/>All diese Zeit über hat<rs type="direct" ref="plc:Thueringen">Thüringen</rs>abwechselnd<hi>Grafen</hi>, <hi>Richter</hi>,<hi>Herzzöge</hi>, <hi>Markgrafen</hi>,die von den Kaisern eingesetzt werden und malfreier, mal abhängiger<rs type="indirect" ref="plc:Thueringen">das Land</rs> regiren.<tei:head xmlns:tei="http://www.tei-c.org/ns/1.0" type="default" subtype="section">III. <rs type="direct" ref="plc:Thueringen">
<hi>Thüringen</hi>
</rs>unter den <rs type="direct" ref="psn:Thueringen_Landgrafen">
<hi>Landgrafen</hi>
......@@ -786,7 +770,6 @@
<tei:handShift xmlns:tei="http://www.tei-c.org/ns/1.0" new="#Fontane" script="standard"/>
<pb n="10v"/>
<pb n="11r"/>
<milestone unit="paragraph"/>
<handShift new="#Fontane" script="clean"/>
<rs type="direct" ref="psn:Heinrich_Raspe">Heinrich Raspe </rs>warder letzte aus dem <rs type="direct" ref="psn:Ludowinger">Stamm</rs>
<rs type="direct" ref="psn:Ludwig_der_Baertige">Ludwigs des <hi>Bärtigen</hi>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment