Commit b2d327aa authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

* fix #119

* remove unused (old) functions
parent 896d9217
......@@ -5,7 +5,7 @@ xquery version "3.1";
: the index for a single notebook.
: The corresponding viewer module is `index-viewer.xqm`.
: @author Mathias Göbel
: @version 1.0
: @version 1.0.1
: @see https://fontane-nb.dariah.eu/register.html
:)
module namespace ixp="http://fontane-nb.dariah.eu/index-processor";
......@@ -25,7 +25,7 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare variable $ixp:metaCollection := '/db/sade-projects/textgrid/data/xml/meta/';
declare variable $ixp:targetStart := "http://textgridrep.org/textgrid:";
(: try/catch here, to pass the tests when no request object is available :)
(: try/catch here, to pass the tests where no request object is available :)
declare variable $ixp:getEntity := try {request:get-parameter('e', '')} catch * {""};
declare variable $ixp:getIndex := try {request:get-parameter('i', '')} catch * {""};
declare variable $ixp:notebookParam := try {request:get-parameter('nb', '')} catch * {""};
......@@ -489,77 +489,19 @@ return
}
};
(:~
: a list item with a list of links
:)
declare function ixp:links($links as element(tei:link)*)
as element(xhtml:li) {
let $notebookUris :=
$links ! (substring-after(./@target, $ixp:targetStart) => substring(1,5) => distinct-values())
let $linkMap as map() :=
map:new(
for $nb in $notebookUris
return
map:entry($nb, $links[contains(@target, $nb)])
)
return
element xhtml:li {
attribute class { "links" },
if(count(map:keys($linkMap)) lt 2) then 'In Notizbuch' else 'In den Notizbüchern',
element xhtml:ul {
ixp:link($linkMap)
}
}
};
(:~
: create list items containing links
: :)
declare function ixp:link($map as map()*)
as element(xhtml:li)* {
for $tguri in map:keys($map)
let $resolve := ixp:resolve-name($tguri)
order by $resolve
return
element xhtml:li {
replace($resolve, "([A-E])0(\d)", "$1$2") || ": ",
element xhtml:ul {
attribute class {"link-list-horizontal"},
let $this-map := $map($tguri)
let $surface-sequence := $this-map ! (./@target => substring-after("surface[@n='") => substring-before("']/"))
for $link at $pos in $this-map
let $page := $link/@target => substring-after("surface[@n='") => substring-before("']/")
let $index-of := index-of($surface-sequence, $page)
let $count := count( $index-of )
where $pos = $index-of[1]
return
element xhtml:li {
element xhtml:a {
attribute href {
"edition.html?id=%2Fxml%2Fdata%2F" || $tguri
|| ".xml&page=" || $page
|| "&target=" || string($link/parent::tei:*/parent::tei:*/@xml:id)
},
f-misc:n-translate($page),
if($count eq 1) then ()
else (" ", <xhtml:span title="Anzahl an Vorkommnissen auf dieser Seite">({$count})</xhtml:span>)
}
}
}
}
};
(:~ renewed version of the linking function
: generates a XHTML list with all links without using the tei:link[@corresp]
: from the entity. it queries the database for what is really mentioned.
: @version 2.0
:)
declare function ixp:links-new($entity as element()) {
declare function ixp:links($entity as element()) {
let $id := string($entity/@xml:id)
let $prefix := ixp:get-prefix-by-entity($entity)
let $reference := $prefix || ":" || $id
let $hits := $ixp:dataCollection//tei:rs[contains(@ref, $reference)][not(@prev)]
let $hits := $ixp:dataCollection//tei:rs
[contains(@ref, $reference)]
[not(@prev)]
[@ref eq $reference]
let $array :=
array{
......@@ -849,7 +791,7 @@ return
(: bibl :)
ixp:bibl($bibl),
(: links :)
ixp:links-new($event),
ixp:links($event),
ixp:li-code($event)
}
}
......@@ -970,7 +912,7 @@ return
(: bibl :)
ixp:bibl($bibl),
(: links :)
ixp:links-new($org),
ixp:links($org),
ixp:li-code($org)
}
}
......@@ -1166,7 +1108,7 @@ else
(: bibl :)
ixp:bibl($bibl),
(: links :)
ixp:links-new($pers),
ixp:links($pers),
ixp:li-code($pers)
}
}
......@@ -1330,7 +1272,7 @@ else
(: former_or_current_location :)
ixp:has-former-or-current-location($formerCurrentLocation),
(: links :)
ixp:links-new($place),
ixp:links($place),
ixp:li-code($place),
element xhtml:ul {
for $plac in $place/tei:place
......@@ -1495,7 +1437,7 @@ else
(: former_or_current_location :)
ixp:has-former-or-current-location($formerCurrentLocation),
(: links :)
ixp:links-new($work),
ixp:links($work),
ixp:li-code($work),
(: further entities :)
for $listPerson in $work/tei:listPerson
......
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