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

Merge branch 'feature/#102-summarize-elements' into 'develop'

Feature/#102 summarize elements

Closes #102

See merge request !41
parents 824a1c99 deac81ef
......@@ -158,6 +158,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
(: this matches the FIRST element of the virtual aggregation :)
if($node/@next and not($node/@prev)) then
element xhtml:ul {
attribute class {"nb-list"},
simple2xhtml:apply-next-element($node)
}
(: this matches all OTHER elements of the virtual aggregation :)
......@@ -165,6 +166,7 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
()
else
element xhtml:ul {
attribute class {"nb-list"},
simple2xhtml:recursion($node/node())
}
......@@ -242,7 +244,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
and not(ends-with($node/preceding::text()[1], "@P"))) then
()
else if(ends-with($node/preceding::text()[1], "@P")) then
else if(ends-with($node/preceding::text()[1], "@P")
or ends-with($node/preceding::text()[1], "-")) then
()
else if($node/preceding-sibling::*[1][self::tei:rs[concat('#', @xml:id) = $node/following-sibling::*[2][self::tei:rs]/@prev]]) then
......@@ -288,16 +291,22 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
}
}
else if($node/@type = ("caret", "footnote-mark")) then
else if($node/@type = ("caret")) then
()
else if($node/@type = "footnote-mark") then
element xhtml:seg {
attribute class {"nb-" || $node/@type},
simple2xhtml:recursion($node/node())
}
else if($node/@type = "short-paragraph-line") then
element xhtml:div {
attribute class {$node/@type}
}
else if($node/@type = "paragraph" and $node/string = "z") then
(element xhtml:br{},
(element xhtml:br {},
element xhtml:div {
attribute class {"nb-paragraph"}
})
......@@ -378,6 +387,11 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
attribute class {"editorial-note"},
simple2xhtml:recursion($node/node())
}
else if($node/@subtype = "footnote") then
element xhtml:div {
attribute class {"nb-footnote"},
simple2xhtml:recursion($node/node())
}
else
()
......
......@@ -54,6 +54,15 @@ declare function fsort:sort($nodes as node()*, $log as xs:string) {
case element(tei:zone) return
fsort:default-return($node, $log)
case element(tei:line) return
fsort:default-return($node, $log)
case element(tei:seg) return
fsort:default-return($node, $log)
case element(tei:rs) return
fsort:default-return($node, $log)
(: case element(tei:hi) return:)
(: if($node/@next and not($node/ancestor::tei:rs)) then:)
(: let $corresp-node := fsort:find-corresp-node($node, "next"):)
......
......@@ -35,10 +35,9 @@ declare function tidySimple:main($tei as node()*, $uri as xs:string) {
=> tidySimple:sort-out-surplus-elements()
=> tidySimple:sort-out-invalid-hands()
=> tidySimple:whitespaces()
(: => tidySimple:summarize-entries():)
=> tidySimple:split-headings()
=> tidySimple:remove-surplus-lines()
=> tidySimple:summarize-rs()
=> tidySimple:summarize()
(: => tidySimple:sort():)
(: let $text-with-sections := tidySimple:make-structure($clear-surplus-hands):)
let $header :=
......@@ -173,6 +172,16 @@ as node()* {
tidySimple:sort-out-surplus-elements($node/node())
}
case element(tei:div) return
if($node/@type = "label"
and not($node/* or $node/node())) then
()
else
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
tidySimple:sort-out-surplus-elements($node/node())
}
default return
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
......@@ -213,16 +222,14 @@ 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 if($flag = "hs-enhance") then
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 = "summarize") then
tidySimple:summarize($node/node())
else if($flag = "ref") then
tidySimple:get-references-in-abstract($node/node())
else
......@@ -490,32 +497,6 @@ declare function tidySimple:split-headings($nodes as node()*) as 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 and not($node/@prev)) then
let $this-content := $node/descendant::text()[not(ancestor::tei:index)]
=> string-join(" ")
let $bla := util:log-system-out($this-content)
return
element tei:hi {
$this-content,
tidySimple:get-next-content($node, ())
}
else if($node[@prev]) then
()
else
tidySimple:copy-element($node, "summarize")
default return
tidySimple:copy-element($node, "summarize")
};
declare function tidySimple:get-next-content($node as node()*, $content as node()*)
as node()* {
......@@ -596,7 +577,7 @@ declare function tidySimple:remove-surplus-lines($nodes as node()*) as node()* {
};
declare function tidySimple:summarize-rs($nodes as node()*) as node()* {
declare function tidySimple:summarize($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
......@@ -607,26 +588,90 @@ declare function tidySimple:summarize-rs($nodes as node()*) as node()* {
$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 tei: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
tidySimple:summarize-entries($node)
case element(tei:list) return
tidySimple:summarize-entries($node)
case element(tei:item) return
tidySimple:summarize-entries($node)
case element(tei:hi) return
tidySimple:summarize-entries($node)
case element(tei:seg) return
tidySimple:summarize-entries($node)
default return
tidySimple:copy-element($node, "summarize")
};
declare function tidySimple:summarize-entries($node as node()) as node()* {
(: the first element of a virtual aggregation:)
if($node/@next and not($node/@prev)) then
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/(@* except @next),
tidySimple:apply-all-nexts($node)
}
else if($node/@prev) then
()
(: nodes that aren't part of the virtual aggregation :)
else
tidySimple:copy-element($node, "summarize")
};
declare function tidySimple:apply-all-nexts($node as node()) as node()* {
(: entry point of virtual aggregation:)
if($node/@next and not($node/@prev)) then
let $next-node := tidySimple:find-corresp-node($node, "next")
return
if(count($next-node) = 1) then
(tidySimple:summarize($node/node()),
tidySimple:apply-all-nexts($next-node))
else
()
(: last of a virtual aggregation: exit point :)
else if(not($node/@next)) then
($node/preceding::tei:milestone[@unit = "handshift"][1],
tidySimple:summarize($node/node()))
(: element in the middle of a virtual aggregation:)
else
let $next-node := tidySimple:find-corresp-node($node, "next")
let $prev-handshift := $node/preceding::tei:milestone[@unit = "handshift"][1]
return
if(count($next-node) = 1) then
($prev-handshift,
tidySimple:summarize($node/node()),
tidySimple:apply-all-nexts($next-node))
else
tidySimple:copy-element($node, "rs")
()
};
default return
tidySimple:copy-element($node, "rs")
declare function tidySimple:find-corresp-node($node as node(), $flag as xs:string) {
let $target-id :=
if($flag = "next") then
tidySimple:get-id($node/@next)
else if($flag = "prev") then
tidySimple:get-id($node/@prev)
else
error(QName("FONTANE", "tidySimple001"), "Invalid flag: " || $flag || "." )
return
$node/root()//*[@xml:id = $target-id]
};
declare function tidySimple:get-id($target as xs:string) as xs:string {
$target => replace("#", "")
};
(:
: Resolves all tei:ptr in a tei:abstract (which is displayed in the Ueberblicks-
: kommentar) and places the resp. abbreviated bibliographical reference instead.
......
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