Commit b1e6fdd0 authored by mrodzis's avatar mrodzis 🌿
Browse files

Merge branch 'feature/#87-resolve-references' into 'develop'

Summarize tei:rs, remove surplus lines, resolve bibliographic references

See merge request !24
parents c3800700 40563e73
......@@ -37,9 +37,13 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) {
=> tidySimple:whitespaces()
(: => tidySimple:summarize-entries():)
=> tidySimple:split-headings()
=> tidySimple:remove-surplus-lines()
=> tidySimple:summarize-rs()
(: => tidySimple:sort():)
(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):)
let $header := tidySimple:get-Fontanes-sources($tei//tei:teiHeader[parent::tei:TEI])
let $header :=
tidySimple:get-Fontanes-sources($tei//tei:teiHeader[parent::tei:TEI])
=> tidySimple:get-references-in-abstract()
let $id-parts := tokenize($tei//tei:TEI/@id, " ")
let $key1 := substring($id-parts[2], 1, 1)
let $key2 := substring($id-parts[2], 2)
......@@ -215,6 +219,12 @@ declare function tidySimple:copy-element($node as node(), $flag as xs:string)
tidySimple:enhance-handshifts($node/node())
else if($flag = "sources") then
tidySimple:get-Fontanes-sources($node/node())
else if($flag = "lines") then
tidySimple:remove-surplus-lines($node/node())
else if($flag = "rs") then
tidySimple:summarize-rs($node/node())
else if($flag = "ref") then
tidySimple:get-references-in-abstract($node/node())
else
tidySimple:tidy($node/node())
}
......@@ -555,3 +565,95 @@ declare function tidySimple:get-Fontanes-sources($header as node()*) {
default return
tidySimple:copy-element($node, "sources")
};
declare function tidySimple:remove-surplus-lines($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case comment() return
$node
case element(tei:milestone) return
if($node[@unit = 'line']
and $node/preceding-sibling::*[1][self::tei:rs[@next]]) then
let $target-id := replace($node/preceding-sibling::*[1][self::tei:rs]/@next, "#", "")
return
if($node/following-sibling::node()[1][self::tei:rs][@xml:id = $target-id]) then
()
else
tidySimple:copy-element($node, "lines")
else
tidySimple:copy-element($node, "lines")
default return
tidySimple:copy-element($node, "lines")
};
declare function tidySimple:summarize-rs($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case comment() return
$node
case element(tei:rs) return
if($node/@next) then
let $target-id := replace($node/@next, "#", "")
return
if($node/following-sibling::node()[1][self::tei:rs][@xml:id = $target-id]) then
element {QName("http://www.tei-c.org/ns/1.0", "rs")} {
$node/(@* except @next),
$node/node(),
$node/following-sibling::node()[1][self::tei:rs][@xml:id = $target-id]/node()
}
else
tidySimple:copy-element($node, "rs")
else if($node/@prev) then
()
else
tidySimple:copy-element($node, "rs")
default return
tidySimple:copy-element($node, "rs")
};
(:
: Resolves all tei:ptr in a tei:abstract (which is displayed in the Ueberblicks-
: kommentar) and places the resp. abbreviated bibliographical reference instead.
:
: @param $nodes Nodes within the tei:teiHeader
: @return processed nodes
: @author Michelle Weidling
:)
declare function tidySimple:get-references-in-abstract($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case comment() return
()
case element(tei:ptr) return
if($node/ancestor::tei:abstract) then
let $target-id := replace($node/@target, "#", "")
let $abbrev := index-info:get-info-about("lit", $target-id, "abbrev")
return
text{$abbrev || " "}
else
tidySimple:copy-element($node, "ref")
default return
tidySimple:copy-element($node, "ref")
};
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