Commit 3b1a9457 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

increase performance on link creation

parent 6ba94a97
......@@ -31,8 +31,7 @@ declare variable $ixp:getIndex := try {request:get-parameter('i', '')} catch * {
declare variable $ixp:notebookParam := try {request:get-parameter('nb', '')} catch * {""};
declare variable $ixp:getNotebook := $ixp:targetStart || $ixp:notebookParam;
declare variable $ixp:dataPath := '/db/sade-projects/textgrid/data/xml/data/';
declare variable $ixp:dataCollection := collection($ixp:dataPath);
declare variable $ixp:dataCollection := collection($config:data-root || "/data");
(:~
: Helper function to collect all main nodes from the index files.
......@@ -535,15 +534,20 @@ as element(xhtml:li)* {
declare function ixp:links-new($entity as element()) {
let $id := string($entity/@xml:id)
let $mentions := $ixp:dataCollection//tei:rs[contains(@ref, ":" || $id)][not(@prev)]
let $countOverAll := count($mentions)
let $base-uris := ($mentions ! base-uri()) => distinct-values()
let $countNotebooks := count($base-uris)
return
element xhtml:li {
attribute class { "links" },
if(count($base-uris) = 1) then 'In Notizbuch' else 'In den Notizbüchern',
if($countNotebooks = 1) then 'In Notizbuch' else ('In den Notizbüchern ',
<span style="color:gray">({$countNotebooks} Notizbücher, insgesamt {$countOverAll} Vorkommnisse)</span>),
element xhtml:ul {
(: main list :)
for $uri in $base-uris
let $pageList := $mentions[base-uri() = $uri] ! ./ancestor::tei:surface[last()]/string(@n)
(: let $pageList := $mentions[base-uri() = $uri] ! ./ancestor::tei:surface[last()]/string(@n):)
let $doc := doc($uri)
let $pageList := $doc//tei:rs[contains(@ref, ":" || $id)][not(@prev)]/ancestor::tei:surface[parent::tei:sourceDoc]
let $tguri := ($uri => tokenize("/"))[last()]
let $resolve := ixp:resolve-name(substring-before($tguri, ".xml"))
let $name := $resolve => replace("([A-E])0(\d)", "$1$2")
......@@ -553,18 +557,17 @@ return
$name || ": ",
element xhtml:ul {
attribute class {"link-list-horizontal"},
for $page in distinct-values($pageList)
let $surface := doc($uri)//tei:surface[@n = $page]
let $count := index-of($pageList, $page) => count()
for $surface in $pageList
let $count := count( $surface//tei:rs[contains(@ref, ":" || $id)][not(@prev)] )
return
element xhtml:li {
element xhtml:a {
attribute href {
"edition.html?id=%2Fxml%2Fdata%2F" || $tguri
|| "&amp;page=" || $page
|| "&amp;page=" || string($surface/@n)
|| "&amp;target=" || $id
},
f-misc:n-translate($page),
f-misc:n-translate(string($surface/@n)),
if($count eq 1) then ()
else (" ", <xhtml:span title="Anzahl an Vorkommnissen auf dieser Seite">({$count})</xhtml:span>)
}
......
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