literaturverzeichnis.xqm 9.64 KB
Newer Older
Mathias Goebel's avatar
Mathias Goebel committed
1
xquery version "3.1";
mrodzis's avatar
mrodzis committed
2
3
4
5
6
7
8
9
10
11
12
13


(:~
 : This module handles the creation of the literature overview at
 : literaturvz.html.
 :
 : @version 1.1
 : @author Mathias Göbel
 : @author Michelle Weidling
 :)


Mathias Goebel's avatar
Mathias Goebel committed
14
15
16
17
18
19
20
21
module namespace fontaneLitVZ="http://fontane-nb.dariah.eu/LitVZ";

declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xhtml="http://www.w3.org/1999/xhtml";

declare default element namespace "http://www.tei-c.org/ns/1.0";

declare function fontaneLitVZ:litvz(){
mrodzis's avatar
mrodzis committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    let $id := request:get-parameter('id', '')
    let $doc := doc('/db/sade-projects/textgrid/data/xml/data/25547.xml')
    let $tabs :=
        <ul class="nav nav-tabs" style="font-size: smaller;">{
            for $list at $pos in $doc//text/body/listBibl
            where $list//bibl/*
            return
                <li class="{if($id != '' and $list//*[replace(string(@xml:id), '\.', '_')=$id]) then 'active' else ()}">
                    <a data-toggle="tab" href="#{$list/@n}">{replace(string($list/@type), '_', ' ')}</a>
                </li>
                }</ul>
    let $tabcon :=
        for $list at $pos in $doc//text/body/listBibl
            return  <div id="{$list/@n}" class="tab-pane{if($id != '' and $list//*[replace(string(@xml:id), '\.', '_')=$id]) then ' active' else ()}">
                        <div id="accordionA" class="panel-group" aria-multiselectable="true" role="tablist">
    {for $item at $po in $doc//text/body/listBibl[$pos]/*

    return
        typeswitch($item)
        case element(listBibl) return
Mathias Goebel's avatar
Mathias Goebel committed
42
43
44
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
mrodzis's avatar
mrodzis committed
45
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapse{$pos}-{$po}">{replace(replace(string($item/@type), '_', ' '), 'ae', 'ä')}</a>
Mathias Goebel's avatar
Mathias Goebel committed
46
47
                    </h4>
                </div>
mrodzis's avatar
mrodzis committed
48
                <div id="collapse{$pos}-{$po}" class="panel-collapse collapse{if($id != '' and $item//*[replace(string(@xml:id), '\.', '_')=$id]) then ' in' else ()}" aria-labelledby="heading{$pos}-{$po}" role="tabpanel">
Mathias Goebel's avatar
Mathias Goebel committed
49
                    <div class="panel-body">
mrodzis's avatar
mrodzis committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
                        <ul>
                            {for $b in $item//bibl where $b/* return
                                let $bid := replace($b/string(@xml:id), '\.', '_')
                                return
                            if($b/ptr[starts-with(@target, '#')])
                            then <li>
                                    {$b//text()}
                                    <ul><li>Den vollständigen Eintrag zu dieser Ausgabe finden Sie <a href="?id={$b/ptr/substring-after(@target, '#')}">hier</a>.</li></ul>
                                </li>
                            else
                                <li class="litvzEintrag{if($id != '' and $bid=$id) then ' fhighlighted' else ()}" id="{$bid}">
                                    <span class="litvzLink"> <a href="literaturvz.html?id={$bid}"><i title="Link zu diesem Eintrag" class="fa fa-link"></i></a> </span>
                                    {$b/choice/abbr/text()}
                                    <ul>
                                        <li>{$b/choice/expan/text()}</li>
                                        {if($b//idno)
                                        then
                                            <li>{string($b/idno/@type)}: {$b/idno/text()||' '}
                                            <a target="_blank" href="{$b/idno/@xml:base||$b/idno/text()}"><i class="fa fa-external-link"></i></a></li> else ()}
                                        {if($b/ptr) then <li>{switch(string($b/ptr/@type)) case 'fulltext' return 'Volltext ' default return string($b/ptr/@type)} <a target="_blank" href="{$b/ptr/@target}"><i class="fa fa-external-link"></i></a></li> else ()}
                                    </ul>
                                </li>
                            }
                        </ul>
Mathias Goebel's avatar
Mathias Goebel committed
74
75
76
                    </div>
                </div>
            </div>
mrodzis's avatar
mrodzis committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

        case element(bibl) return
            (: create a panel, expand the abbreviation and link to target :)
            if(exists($item/preceding-sibling::listBibl) or exists($item/following-sibling::listBibl)) then
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapse{$pos}-{$po}">{string-join($item//text(), ' ')} {if($item/ptr) then '('||$doc//bibl[@xml:id = substring-after($item/ptr/@target, '#')]//expan/text()||')' else ()}</a>
                        </h4>
                    </div>
                    <div id="collapse{$pos}-{$po}" class="panel-collapse collapse " aria-labelledby="heading{$pos}-{$po}" role="tabpanel">
                        <div class="panel-body">
                            <p>
                                Den vollständigen Eintrag zu dieser Ausgabe finden Sie <a href="?id={$item/ptr/substring-after(@target, '#')}">hier</a>.
                            </p>
                        </div>
                    </div>
                </div>
            else
                let $b := $item
                let $bid:= replace($b/string(@xml:id), '\.', '_')
                return
                <ul>
                    <li class="litvzEintrag{if($id != '' and $bid=$id) then ' fhighlighted' else ()}" id="{$bid}">
                            <span class="litvzLink"> <a href="literaturvz.html?id={$bid}"><i title="Link zu diesem Eintrag" class="fa fa-link"></i></a> </span>
                            {$b/choice/abbr}
                            <ul>
                                <li>{$b/choice/expan/text()}</li>
                                {
                                    if($b/choice/expan/ptr) then
                                        <li><a href="{$b/choice/expan/ptr/string(@target)}">{$b/choice/expan/ptr/string(@target)}</a></li>
                                    else
                                        ()
                                }
                                {
                                    if($b/idno) then
                                        <li>{string($b/idno/@type)}: {$b/idno/text()||' '} <a target="_blank" href="{$b/idno/@xml:base||$b/idno/text()}"><i class="fa fa-external-link"></i></a></li>
                                    else
                                        ()
                                }
                                {
                                    if($b/bibl) then
                                        <ul>
                                        {
                                            for $volume in $b/bibl return
                                                (<li>{$volume/choice/expan/text()}</li>,
                                                if($volume/idno) then
                                                    <li>{string($volume/idno/@type)}: {$volume/idno/text()||' '} <a target="_blank" href="{$volume/idno/@xml:base||$volume/idno/text()}"><i class="fa fa-external-link"></i></a></li>
                                                else
                                                    ()
                                                )
                                        }
                                        </ul>
                                    else
                                        ()
                                }
                                {
                                    if($b/ptr) then
                                        <li>
                                            {
                                                switch(string($b/ptr/@type))
                                                case 'fulltext' return 'Volltext '
                                                default return string($b/ptr/@type)
                                            }
                                            <a target="_blank" href="{$b/ptr/@target}"><i class="fa fa-external-link"></i></a>
                                        </li>
                                    else ()
                                }
                            </ul>
                        </li>
                </ul>

        default return
Mathias Goebel's avatar
Mathias Goebel committed
150
            let $b := $item
mrodzis's avatar
mrodzis committed
151

Mathias Goebel's avatar
Mathias Goebel committed
152
153
154
155
156
            return
            <ul>
                <li>
                    {$b//abbr}
                    <ul>
Mathias Goebel's avatar
Mathias Goebel committed
157
                        <li>{$b//expan//text()}</li>
mrodzis's avatar
mrodzis committed
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
                        {
                            if($b/choice/expan/ptr) then
                                <li><a href="{$b/choice/expan/ptr/string(@target)}">{$b/choice/expan/ptr/string(@target)}</a></li>
                            else
                                ()
                        }
                        {
                            if($b//idno) then
                                <li>{string($b//idno/@type)}: {$b//idno/text()||' '} <a target="_blank" href="{$b//idno/@xml:base||$b//idno/text()}"><i class="fa fa-external-link"></i></a></li>
                            else
                                ()
                        }
                        {
                            if($b//ptr) then
                                <li>{string($b//ptr/@type)} <a target="_blank" href="{$b//ptr/@target}"><i class="fa fa-external-link"></i></a></li>
                            else
                                ()
                        }
Mathias Goebel's avatar
Mathias Goebel committed
176
177
                    </ul>
                </li>
mrodzis's avatar
mrodzis committed
178
179
180
            </ul>
    }
                        </div>
Mathias Goebel's avatar
Mathias Goebel committed
181
182
                    </div>

mrodzis's avatar
mrodzis committed
183
184
185
186
187
188
189
    return
        (    <div class="container litvz">
            {$tabs}
            <div class="tab-content">
                {$tabcon}
            </div>
        </div>)
Mathias Goebel's avatar
Mathias Goebel committed
190
};