Commit be5fb474 authored by Mathias Goebel's avatar Mathias Goebel 🎠 Committed by mrodzis
Browse files


parent 6518f352
xquery version "3.1";
: This module parses all TEI documents and creates an over-all table of contents.
: @author Mathias Göbel
: @version 0.1
: @since v4.7.0
module namespace f-content="";
import module namespace config="" at "../config/config.xqm";
declare namespace tei="";
declare namespace test="";
declare namespace tgmd="";
declare namespace xhtml="";
: The main function returns a complete over-all index.
: @param $node The current node prepared by the templating engine
: @param $model Stores any arbitrary information to pass-through templating functions
declare function f-content:main($node as node(), $model as map(*)) {
<xhtml:ul class="gesamtinhaltsverzeichnis">
{for $item in collection($config:data-root || "/data")//tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msContents/tei:ab/tei:list[@type="editorial"]/tei:item
let $order := upper-case(string($item)) => replace("^\W+", "")
let $group := $order => substring(1, 1)
stable order by $order
group by $group
for $i in $item
let $nbname := $i/root()/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title[1]/substring-after(., " ")
<xhtml:li class="tocItem"><xhtml:span class="nbname">[{$nbname}]</xhtml:span> {local:renderTOCitem($i)}</xhtml:li>
: Prepares all content of tei:item from within tei:msContent. Recursion.
: @param $item The tei:item or any content from within via recursion
declare function local:renderTOCitem($item) {
let $uri := try{$item/base-uri() => substring-after("data/")}catch*{()}
for $n in $item/node() return
case element(tei:item) return
case element(tei:ref) return
element xhtml:a {
attribute href {
if(starts-with($n/@target, "#xpath"))
'edition.html?id=/'|| $uri ||'&amp;page='||substring-before(substring-after($n/@target, "@n='"), "'])")
'edition.html?id=/'|| $uri ||'&amp;page='||substring-before(substring-after($n/@target, "_"), "_")||'&amp;target='||substring-after($n/@target, "#")
case element(tei:rs) return
let $ref := $n/string(@ref)
let $type := substring-before($ref, ':')
let $link := switch($type)
case 'lit' return 'literaturvz.html?id='||substring-after($ref, ':')
default return 'TODOvz.html'
return <xhtml:a href="{$link}">{$n/text()}</xhtml:a>
case text() return
default return
......@@ -6,6 +6,7 @@
xquery version "3.1";
import module namespace config="" at "config/config.xqm";
import module namespace f-content="" at "fontane/inhaltsverzeichnis.xqm";
import module namespace f-misc="" at "fontane/misc.xqm";
import module namespace f-render="" at "fontane/render.xqm";
import module namespace fsearch = "http://sade/faceted-search" at "faceted-search/faceted-search.xqm";
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