Commit 6bddd39f authored by mrodzis's avatar mrodzis 🌎
Browse files

Summarize tei:hi that belong together (cf. print#64)

parent 5fd3e0f6
......@@ -35,6 +35,7 @@ declare function tidySimple:main($tei as node()*) {
let $tidy := tidySimple:sort-out-invalid-hands($tei//tei:text)
=> tidySimple:sort-out-surplus-elements()
=> tidySimple:whitespaces()
=> tidySimple:summarize-entries()
=> tidySimple:split-headings()
(: => tidySimple:sort():)
(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):)
......@@ -184,6 +185,8 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string)
tidySimple:sort-out-invalid-hands($node/node())
else if($flag = "surplus") then
tidySimple:sort-out-invalid-hands($node/node())
else if($flag = "summarize") then
tidySimple:summarize-entries($node/node())
else
tidySimple:tidy($node/node())
}
......@@ -399,3 +402,30 @@ declare function tidySimple:split-headings($nodes as node()*) as node()* {
tidySimple:split-headings($node/node())
}
};
declare function tidySimple:summarize-entries($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case element(tei:hi) return
if($node[@next]) then
let $this-content := $node/child::text()
let $next-content := $node/following-sibling::tei:hi[1]/child::text()
let $break := if($node/@break = "true") then text{" "} else ()
let $content := ($this-content, $break, $next-content)
return
element {QName("http://www.tei-c.org/ns/1.0", "hi")} {
$content
}
else if($node[@prev]) then
()
else
tidySimple:copy-element($node, "summarize")
default return
tidySimple:copy-element($node, "summarize")
};
\ No newline at end of file
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