Commit a6187015 authored by MRodz's avatar MRodz
Browse files

Ignore elements that belong to invalid hands and improve omission handling for structures

parent 34e3cd4f
......@@ -23,6 +23,18 @@ declare
tidySimple:sort-out-invalid-hands($node)
};
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: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>")
function tidysimple-test:handShift-invalid($node as element(*)) {
tidySimple:sort-out-invalid-hands($node)
};
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>")
......
......@@ -65,9 +65,27 @@ as node()* {
tidySimple:copy-element($node, "post")
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")
default return
tidySimple:copy-element($node, "post")
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")
};
......@@ -132,13 +150,16 @@ declare function tidySimple:make-structure($nodes as node()*) as node()* {
tidySimple:copy-element($node, "structure")
default return
if($node/preceding::tei:milestone/@spanTo
and $node/following::tei:anchor[matches(preceding::tei:milestone/@spanTo, @xml:id)]
or $node/preceding::tei:milestone[@unit = "paragraph"]
and $node/preceding::tei:milestone[@unit = "paragraph"]) then
()
else
tidySimple:copy-element($node, "structure")
let $prev-section-marker := $node/preceding::tei:milestone[1][@spanTo]
let $target-id := replace($prev-section-marker, "#", "")
let $next-anchor := $node/following::tei:anchor[matches(@xml:id, $target-id)]
let $next-p := $node/following::tei:milestone[@unit = "paragraph"][1]
return
if($prev-section-marker and $next-anchor
or $next-p and tidySimple:is-second-part-of-pair($next-p)) then
()
else
tidySimple:copy-element($node, "structure")
};
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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