Commit b7714f71 authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Further work on 8ed96f3e

parent 7473e5b9
......@@ -788,7 +788,7 @@ as element(tei:pb) {
};
declare function fontaneSimple:enhance-handshift($node as element(tei:handShift))
as element(tei:handShift) {
as element(tei:milestone) {
let $prev-hand := $node/preceding::tei:handShift[@new][1]
return
element tei:milestone {
......
......@@ -19,11 +19,11 @@ import module namespace functx = "http://www.functx.com";
(: TODO: adapt to general XML :)
(:~
: Determines whether the passed tei:handShift is contemporary or not.
: Determines whether the passed tei:milestone is contemporary or not.
:
: TODO: check if we reach backside of calendar pages at all
: @author Michelle Rodzis
: @param $hand the tei:handShift/@new or tei:mod/@hand to be checked
: @param $hand the tei:milestone/@subtype or tei:mod/@hand to be checked
: @return xs:boolean
:)
declare function simpleHelpers:is-hand-contemporary($hand as xs:string?)
......@@ -163,7 +163,7 @@ declare function simpleHelpers:has-valid-text($node as node()) as xs:boolean {
: @return xs:boolean
:)
declare function simpleHelpers:is-valid-text($node as text()) as xs:boolean {
let $current-hand := $node/preceding::tei:handShift[@new][1]/@new
let $current-hand := $node/preceding::tei:milestone[@type = "handshift"][@subtype][1]/@subtype
return
if((simpleHelpers:is-hand-contemporary($current-hand)
or ($node[ancestor::tei:surface[@type = "label"]]
......@@ -284,12 +284,12 @@ declare function simpleHelpers:filter-rendition($node as node()) as xs:string* {
: @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
: @param $node the current tei:milestone[@type = "handshift"] element
: @return xs:boolean
:)
declare function simpleHelpers:is-hand-valid($hands as xs:string*,
$node as element(tei:handShift)) as xs:boolean {
let $current-hand := replace($node/@new, "#", "")
$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::tei:div[@type = "label"]
......@@ -304,13 +304,14 @@ $node as element(tei:handShift)) as xs:boolean {
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 :)
tei:milestone[@type = "handshift"] because the initial pages are empty.
in these cases we want to preserve the element and therefore set a valid
tei:milestone[@type = "handshift"] :)
let $prev-hand :=
if($node/preceding::tei:handShift[1]) then
$node/preceding::tei:handShift[1]
if($node/preceding::tei:milestone[@type = "handshift"][1]) then
$node/preceding::tei:milestone[@type = "handshift"][1]
else
<tei:handShift new="#Fontane"/>
<tei:milestone type="handshift" subtype="#Fontane"/>
return
if(simpleHelpers:is-hand-valid($hands, $prev-hand)) then
true()
......@@ -320,53 +321,53 @@ $node as element(*)*) as xs:boolean {
declare function simpleHelpers:find-prev-valid-hand($hands as xs:string*,
$node as element(tei:handShift)) as element(tei:handShift){
$node/preceding::tei:handShift[1][simpleHelpers:is-hand-valid($hands, $node)]
$node as element(tei:milestone)) as element(tei:milestone){
$node/preceding::tei:milestone[@type = "handshift"][1][simpleHelpers:is-hand-valid($hands, $node)]
};
(:~
: Checks if the previous handShift is the same as the current handShift. Two
: handShifts are the same if they have the same attributes.
: Checks if the previous milestone[@type = "handshift"] is the same as the
: current milestone[@type = "handshift"]. They are the same if they have the
: same attributes.
:
: @author Michelle Rodzis
: @param $node the current tei:handShift element
: @param $node the current tei:milestone[@type = "handshift"] element
: @return xs:boolean
:)
declare function simpleHelpers:is-prev-valid-hand-same($hands as xs:string,
$node as element(tei:handShift)) as xs:boolean {
$node as element(tei:milestone)) as xs:boolean {
let $prev-valid-hand := simpleHelpers:find-prev-valid-hand($hands, $node)
let $prev-hand := $node/preceding::tei:handShift[1]
let $prev-hand := $node/preceding::tei:milestone[@type = "handshift"][1]
return
(: since we can't take the order of the attributes for granted we can't
use functx:sequence-deep-equal :)
if($prev-hand
and $prev-hand = $prev-valid-hand
and $node/@new = $prev-hand/@new
and $node/@script = $prev-hand/@script
and $node/@medium = $prev-hand/@medium) then
and $node/@subtype = $prev-hand/@subtype
and $node/@rend = $prev-hand/@rend) then
true()
else
false()
};
(:~
: Checks if the previous handShift is the same as the current handShift. Two
: handShifts are the same if they have the same attributes.
: Checks if the previous milestone[@type = "handshift"] is the same as the
: current milestone[@type = "handshift"]. They are the same if they have the
: same attributes.
:
: @author Michelle Rodzis
: @param $node the current tei:handShift element
: @param $node the current tei:milestone[@type = "handshift"] element
: @return xs:boolean
:)
declare function simpleHelpers:is-prev-hand-same($node as element(tei:handShift))
declare function simpleHelpers:is-prev-hand-same($node as element(tei:milestone))
as xs:boolean {
let $prev-hand := $node/preceding::tei:handShift[1]
let $prev-hand := $node/preceding::tei:milestone[@type = "handshift"][1]
return
(: since we can't take the order of the attributes for granted we can't
use functx:sequence-deep-equal :)
if($prev-hand
and $node/@new = $prev-hand/@new
and $node/@script = $prev-hand/@script
and $node/@medium = $prev-hand/@medium) then
and $node/@subtype = $prev-hand/@subtype
and $node/@rend = $prev-hand/@rend) then
true()
else
false()
......
......@@ -13,11 +13,11 @@ declare namespace test="http://exist-db.org/xquery/xqsuite";
(: handshifts :)
declare
%test:name("handShift - Sort out invalid ones")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Stempel2""/>")
%test:args("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Stempel2""/>")
%test:assertEmpty
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latf""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latf""/>")
%test:args("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf) medium()""/>")
%test:assertEquals("<milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf) medium()""/>")
function tidysimple-test:handShift-invalid($node as element(*)) {
tidySimple:sort-out-invalid-hands($node)
......@@ -25,13 +25,13 @@ declare
declare
%test:name("handShift - Sort out invalid nodes after an invalid hand")
%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""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</seg></body>")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</seg></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/></body>")
%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""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""black_ink"" script=""Latn clean""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Text von Fontane</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""black_ink"" script=""Latn clean""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Text von Fontane</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Friedrich_Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Dieses Buch hat 52 Blatt.</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Text von Fontane</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium(black_ink)""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:small"">Text von Fontane</seg><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""paragraph""/></body>")
%test:args("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" xml:id=""a4""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#fremde_Hand3"" script=""Latn clean"" medium=""""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""align(center)""/>✓ </div>")
%test:args("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" xml:id=""a4""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#fremde_Hand3"" rend=""script(Latn clean) medium()""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""align(center)""/>✓ </div>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0"" type=""label"" xml:id=""a4""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line"" rendition=""align(center)""/></div>")
function tidysimple-test:handShift-invalid($node as element(*)) {
......@@ -40,14 +40,14 @@ declare
declare
%test:name("handShift - Sort out surplus ones")
%test:args("<div xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latf""/>Some text<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn""/></div>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latf""/>Some text<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn""/></div>")
%test:args("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/>Some text<milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/></div>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/>Some text<milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/></div>")
%test:args("<div xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium="""" script=""Latn""/>Some text<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium="""" script=""Latn""/></div>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn""/>Some text</div>")
%test:args("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/>Some text<milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/></div>")
%test:assertEquals("<div xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/>Some text</div>")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latf standard"" medium=""""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script="""" medium=""""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_1"" spanTo=""#C07_3r_s""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn clean"" new=""#Fontane"" medium=""""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></rs></head></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_1"" spanTo=""#C07_3r_s""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn clean"" new=""#Fontane""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></rs></head></body>")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf standard) medium()""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script() medium()""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_1"" spanTo=""#C07_3r_s""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></rs></head></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_1"" spanTo=""#C07_3r_s""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Luther""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Luther</hi></rs></head></body>")
function tidysimple-test:handShift-surplus($node as element(*)) {
tidySimple:sort-out-surplus-hands($node)
......@@ -58,8 +58,8 @@ declare
declare
%test:name("Sections")
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_2"" spanTo=""#C07_4r_s""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean"" medium=""""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large; letter-spacing:0.2cm""><rs type=""direct"" ref=""psn:Cranach""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Lucas Cranach</hi></rs>.</seg></head><handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latf standard"" new=""#Fontane"" medium=""""/><anchor xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_4r_s""/></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><div xmlns=""http://www.tei-c.org/ns/1.0"" type=""section""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean"" medium=""""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large; letter-spacing:0.2cm""><rs type=""direct"" ref=""psn:Cranach""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Lucas Cranach</hi></rs>.</seg></head><handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latf standard"" new=""#Fontane"" medium=""""/></div></body>")
(: %test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""section"" type=""Text_2"" spanTo=""#C07_4r_s""/><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large; letter-spacing:0.2cm""><rs type=""direct"" ref=""psn:Cranach""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Lucas Cranach</hi></rs>.</seg></head><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/><anchor xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_4r_s""/></body>"):)
(: %test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><div xmlns=""http://www.tei-c.org/ns/1.0"" type=""section""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latn clean) medium()""/><head xmlns=""http://www.tei-c.org/ns/1.0"" type=""x-large"" rend=""align(center)""><seg xmlns=""http://www.tei-c.org/ns/1.0"" rendition=""font-size:x-large; letter-spacing:0.2cm""><rs type=""direct"" ref=""psn:Cranach""><hi xmlns=""http://www.tei-c.org/ns/1.0"">Lucas Cranach</hi></rs>.</seg></head><milestone xmlns=""http://www.tei-c.org/ns/1.0"" type=""handshift"" subtype=""#Fontane"" rend=""script(Latf clean) medium()""/></div></body>") :)
%test:args("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Amalberga""><hi xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_7r_d"" prev=""#C07_7r_c"">Amalberga</hi></rs></body>")
%test:assertEquals("<body xmlns=""http://www.tei-c.org/ns/1.0""><milestone xmlns=""http://www.tei-c.org/ns/1.0"" unit=""line""/><rs xmlns=""http://www.tei-c.org/ns/1.0"" type=""direct"" ref=""psn:Amalberga""><hi xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C07_7r_d"" prev=""#C07_7r_c"">Amalberga</hi></rs></body>")
......
......@@ -59,38 +59,45 @@ as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
if($node/preceding::tei:handShift[1]
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node/preceding::tei:handShift[1]))) then
if($node/preceding::tei:milestone[@type = "handshift"][1]
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node/preceding::tei:milestone[@type = "handshift"][1]))) then
()
else
$node
case element(tei:handShift) return
if(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node)) then
tidySimple:clear-handshift($node)
else
()
(: all lines have to be preserved because of the editorial commentary
which references the lines in the notebooks. if we omitted @unit = "line"
referencing wouldn't work any longer :)
case element(tei:milestone) return
if($node/preceding::tei:handShift[1]
and $node/@unit = "line"
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node/preceding::tei:handShift[1]))) then
tidySimple:copy-element($node, "post")
else if($node/preceding::tei:handShift[1]
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node/preceding::tei:handShift[1]))) then
()
else
tidySimple:copy-element($node, "post")
let $prev-handshift := $node/preceding::tei:milestone[@type = "handshift"][1]
return
if($node/@type = "handshift" and
simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node)) then
tidySimple:clear-handshift($node)
else if($node/@type = "handshift") then
()
else if($prev-handshift
and $node/@unit = "line"
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $prev-handshift))) then
tidySimple:copy-element($node, "post")
else if($prev-handshift
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $prev-handshift))) then
()
else
tidySimple:copy-element($node, "post")
default return
if($node/preceding::tei:handShift[1]
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node/preceding::tei:handShift[1]))) then
()
else
tidySimple:copy-element($node, "post")
let $prev-handshift := $node/preceding::tei:milestone[@type = "handshift"][1]
return
if($prev-handshift
and not(simpleHelpers:is-hand-valid($tidySimple:valid-hands, $prev-handshift))) then
()
else
tidySimple:copy-element($node, "post")
};
......@@ -101,12 +108,18 @@ as node()* {
case text() return
$node
case element(tei:handShift) return
if(simpleHelpers:is-prev-hand-same($node)
or not(tidySimple:has-hand-text($node))) then
()
case element(tei:milestone) return
if($node/@type ="handshift") then
if(simpleHelpers:is-prev-hand-same($node)
or not(tidySimple:has-hand-text($node))) then
()
else
tidySimple:clear-handshift($node)
else
tidySimple:clear-handshift($node)
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
tidySimple:sort-out-surplus-hands($node/node())
}
default return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
......@@ -115,9 +128,9 @@ as node()* {
}
};
declare function tidySimple:has-hand-text($node as element(tei:handShift))
declare function tidySimple:has-hand-text($node as element(tei:milestone))
as xs:boolean {
let $next-handshift := $node/following::tei:handShift[1]
let $next-handshift := $node/following::tei:milestone[@type = "handshift"][1]
let $nodes-between := $node/following::node()[. << $next-handshift]
let $is-text-node :=
for $node-between in $nodes-between
......@@ -154,27 +167,24 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string)
};
(:~
: Purges surplus attributes from tei:handShift.
: Purges surplus attributes from tei:milestone[@type = "handshift"].
:
: @author Michelle Rodzis
: @param $node the current tei:handShift
: @return the purged tei:handShift
: @param $node the current tei:milestone[@type = "handshift"]
: @return the purged tei:milestone[@type = "handshift"]
: :)
declare function tidySimple:clear-handshift($node as element(tei:handShift))
as element(tei:handShift) {
element tei:handShift {
if($node/@new = "") then
()
else
$node/@new,
if($node/@script = "") then
declare function tidySimple:clear-handshift($node as element(tei:milestone))
as element(tei:milestone) {
element tei:milestone {
attribute type {"handshift"},
if($node/@subtype = "") then
()
else
$node/@script,
if($node/@medium = "") then
$node/@subtype,
if($node/@rend = "") then
()
else
$node/@medium
$node/@rend
}
};
......
This diff is collapsed.
Markdown is supported
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