Commit 37a55dfd authored by mrodzis's avatar mrodzis 🌿
Browse files

Improve tei:rs handling, remove redundancies

parent f5e6fbc0
......@@ -41,10 +41,8 @@ declare function presort:sort($nodes as node()*) as node()* {
if($node/@next and not($node/@prev)) then
(presort:apply-all-nexts($node))
else if($node/@prev or $node/@next) then
let $prev-id := presort:get-prev-id($node)
let $next-id := presort:get-next-id($node)
let $prev-node := presort:find-corresp-node($node, $prev-id)
let $next-node := presort:find-corresp-node($node, $next-id)
let $prev-node := presort:find-corresp-node($node, "prev")
let $next-node := presort:find-corresp-node($node, "next")
return
if($prev-node or $next-node) then
()
......@@ -70,8 +68,7 @@ declare function presort:keep-node($node as node()*) as node()* {
declare function presort:apply-all-nexts($node as node()*) {
(: entry point :)
if($node/@next and not($node/@prev)) then
let $next-id := presort:get-next-id($node)
let $next-node := presort:find-corresp-node($node, $next-id)
let $next-node := presort:find-corresp-node($node, "next")
return
(presort:keep-node($node),
(: (functx:remove-attributes($node, "next"),:)
......@@ -81,8 +78,7 @@ declare function presort:apply-all-nexts($node as node()*) {
(: functx:remove-attributes($node, "prev"):)
presort:keep-node($node)
else
let $next-id := presort:get-next-id($node)
let $next-node := presort:find-corresp-node($node, $next-id)
let $next-node := presort:find-corresp-node($node, "next")
return
(: (functx:remove-attributes($node, ("next", "prev")),:)
(presort:keep-node($node),
......@@ -98,13 +94,35 @@ declare function presort:get-prev-id($node as node()) {
$node/@prev => replace("#", "")
};
declare function presort:find-corresp-node($node as node()*, $id as xs:string) {
$node/ancestor::*[last()]//*[@xml:id = $id]
declare function presort:find-corresp-node($node as node()*, $flag as xs:string) {
let $id :=
if($flag = "next") then
presort:get-next-id($node)
else if($flag = "prev") then
presort:get-prev-id($node)
else
error(QName("FONTANE", "PRESORT1"), "Invalid flag: " || $flag || "." )
return
$node/ancestor::*[last()]//*[@xml:id = $id]
};
declare function presort:exclude-copied($node as node()) {
declare function presort:exclude-copied($node as node()) as element(tei:rs) {
let $rs-children := $node/node()
let $processed-children :=
for $child in $rs-children return
if($child/@next) then
presort:apply-all-nexts($child)
else if($child/@prev) then
()
else
$child
return
(util:log-system-out($processed-children),
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
$node/node()[not(@prev or @next)]
}
$processed-children
(: $node/node()[not(@prev)]:)
(: $node/node():)
})
};
\ No newline at end of file
......@@ -108,8 +108,6 @@ declare function simpleHelpers:prepare-text($node as text()) as text()? {
text {$cleared-Tironian}
else
()
else if(normalize-space($node) = "" and matches($node, " ")) then
text{" "}
else
()
};
......
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