Commit ddff6cb6 authored by mrodzis's avatar mrodzis 🌎
Browse files

Add first draft for integration brackets (cf. print#35, print#36)

parent a03afc98
......@@ -25,8 +25,9 @@ declare function presort:main($tei as node()*) as element(tei:text) {
(: return $tei:)
let $tei := presort:sort($tei)
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-presort.xml", $tei)
return $tei
let $fully-sorted := presort:sort-integrations($tei)
let $store := xmldb:store("/db/apps/SADE/resources/xml/", "tei-simple-presort.xml", $fully-sorted)
return $fully-sorted
};
declare function presort:sort($nodes as node()*) as node()* {
......@@ -79,7 +80,6 @@ declare function presort:sort($nodes as node()*) as node()* {
else
presort:default-return($node)
default return
presort:default-return($node)
};
......@@ -171,4 +171,45 @@ declare function presort:default-return($node as node()) as node()* {
presort:keep-node($node)
else
presort:keep-node($node)
};
declare function presort:sort-integrations($nodes as node()*) as node()* {
for $node in $nodes return
if($node/@xml:id) then
let $id := $node/@xml:id
let $metamarks := $node/ancestor::*[last()]//tei:metamark[@function = "integrate"]
let $linking-node-corresp := $metamarks[substring-after(@corresp, "#") = $id]
let $linking-node-target := $metamarks[substring-after(@target, "#") = $id]
return
if($linking-node-corresp and not($linking-node-target)) then
let $integration-target-id := replace($linking-node-corresp/@target, "#", "")
let $integration-comment := $linking-node-corresp/ancestor::*[last()]//*[@xml:id = $integration-target-id]
return
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
attribute type {"integration"},
$integration-comment,
$linking-node-corresp,
presort:keep-node-integrations($node)
}
else if($linking-node-target) then
()
else
presort:keep-node-integrations($node)
else if($node[self::tei:metamark[@function = "integrate"]]) then
()
else if($node[self::text() or self::comment()]) then
$node
else
presort:keep-node-integrations($node)
};
declare function presort:keep-node-integrations($node as node()) as node()* {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
(: $node/(@* except (@prev, @next)), (: attrs only visible for debugging :):)
presort:sort-integrations($node/node())
}
};
\ No newline at end of file
......@@ -323,6 +323,12 @@ declare function fontaneSimple:transform($nodes as node()*, $uri as xs:string) a
(),
fontaneSimple:transform($node/node(), $uri)
}
else if($node/@type = "integration") then
element {QName("http://www.tei-c.org/ns/1.0", "seg")} {
$node/@*,
fontaneSimple:transform($node/node(), $uri)
}
else
fontaneSimple:transform($node/node(), $uri)
......
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