ueberblickskommentar.xqm 26.7 KB
Newer Older
Mathias Goebel's avatar
Mathias Goebel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
xquery version "3.1";
module namespace fontaneUeberblickskommentar="http://fontane-nb.dariah.eu/Ueberblickskommentar";

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 fontaneUeberblickskommentar:render($docpath as xs:string) {
let $tei := doc($docpath)//tei:teiHeader,
    $items := for $item at $pos in (1 to 23)
                let $title := switch($pos)
                                case 1 return  "Signatur"
                                case 2 return  "Druckgeschichte"
                                case 3 return  "Inhalt"
                                case 4 return  "Textsorten/Gattungen"
                                case 5 return  "Fontanes Quellen"
                                case 6 return  "Beilagen"
                                case 7 return  "Entstehungszeit/Benutzungszeitraum"
                                case 8 return  "Sprachen"
                                case 9 return  "Schreiberhände"
                                case 10 return "Schreibstoffe und -geräte"
                                case 11 return "Duktus"
                                case 12 return "Druckschriften"
                                case 13 return "Layout"
                                case 14 return "Umfang mit Vorsatzblatt"
                                case 15 return "Format"
                                case 16 return "Einband"
(:                                case 17 return "Taschen":)
                                case 17 return "An- und Aufklebungen"
                                case 18 return "Blattfragmente"
                                case 19 return "Vakat-Seiten"
                                case 20 return "Skizzen"
                                case 21 return "Stempel"
                                case 22 return "Foliierung"
                                case 23 return "Besonderheiten"
                                default return "error",
                $path :=    (
                            "//fileDesc/sourceDesc/msDesc/msIdentifier",
                            "//fileDesc/publicationStmt/ab/listBibl/listBibl[1]",
                            "//fileDesc/sourceDesc/msDesc/msContents/ab/list[@type='editorial']/item",
                            "//profileDesc/textClass/keywords",
                            "//profileDesc/textDesc/derivation/linkGrp/link/",
                            "//msPart",
                            "//profileDesc/creation/date",
                            "//profileDesc/langUsage/language",
                            "//profileDesc/handNotes[ number(@n) lt 7 ]",
                            "//profileDesc/handNotes[ number(@n) = (7,8) ]",
                            "//profileDesc/handNotes[ number(@n) = 9 ]",
                            "//sourceDesc/msDesc/physDesc/typeDesc/ab",
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/layoutDesc/layout",
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/extent/measure/",
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/extent/dimensions",
                            "//fileDesc/sourceDesc/msDesc/physDesc/bindingDesc",
(:                            "//fileDesc/sourceDesc/msDesc/physDesc/accMat",:)
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab[hi/string(.) != 'Vakat-Seiten:'][hi/string(.) != 'Blattfragmente:']",
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab[hi/string(.) = 'Blattfragmente:']",
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab[hi/string(.) = 'Vakat-Seiten:']",
                            "//fileDesc/sourceDesc/msDesc/physDesc/decoDesc/ab[hi/string(.) = 'Skizzen:']",
                            "//fileDesc/sourceDesc/msDesc/physDesc/additions/ab[hi/string(.) = 'Stempel:']",
                            "//fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/foliation",
                            "(//fileDesc/sourceDesc/msDesc/physDesc/handDesc, //fileDesc/sourceDesc/msDesc/physDesc/typeDesc)"
                            ),
                    $content := switch($pos)
                                case 1 return
                                    <ul><li>{$tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/repository/text()}</li>
                                        <ul><li>{$tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/collection/text()}
                                            <ul><li>{$tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/idno/string(@type)}: {$tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/idno/text()}</li>
                                                <li>{$tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/altIdentifier/idno/string(@type)}: {$tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/altIdentifier/idno/text()}</li>
                                                <li>Titel: {if(exists($tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/msName/text())) then $tei/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/msName/text() else 'ohne'}</li>
                                            </ul></li>
                                        </ul>
                                    </ul>
                                case 2 return
                                    <ul>{
                                        for $listBibl in $tei/tei:fileDesc/publicationStmt/ab/listBibl/listBibl[1]
                                        return <li>{$listBibl/head/text()}<ul>{for $item in $listBibl/bibl return <li>{for $text in $item//text()[not(parent::tei:hi)] return local:textref($text)}</li>}</ul></li>
                                    }</ul>
                                case 3 return try {
                                    <ul>
                                        <li>Herausgeber-Inhaltsverzeichnis
82
83
                                            <ul>{for $item in $tei//msContents/ab/list[@type="editorial"]/item return
                                                <li>{for $text in $item//text() where not($text/parent::tei:hi) return local:textref($text)}</li> }
Mathias Goebel's avatar
Mathias Goebel committed
84
85
                                            </ul>
                                        </li>
86
                                    </ul> } catch * { 'error at item 3', <p>{$err:code}: {$err:description}. Data: {$err:value}</p> }
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
                                case 4 return
                                    let $keywordsCat := $tei/profileDesc/textClass/keywords[@scheme]
                                    return
                                        <xhtml:ul>
                                        {for $keyword at $pos in $keywordsCat
                                        return
                                            (if($pos = 2) then <xhtml:hr/> else (),
                                            <xhtml:li class="textClass_cat">
                                                <xhtml:span title="{string($keyword/@scheme)}">
                                                    {if( $keyword//term[. = 'fiction'] ) then "Fiktional" else ()}
                                                    {if( $keyword//term[. = 'non-fiction'] ) then "Nicht-Fiktional" else ()}
                                                </xhtml:span>
                                                <xhtml:ul>
                                                    {for $term in $keyword/following-sibling::tei:keywords[1][not(@scheme)]//tei:term
                                                    return
                                                        <xhtml:li>{string($term)}</xhtml:li>
                                                    }
                                                </xhtml:ul>
                                            </xhtml:li>)
                                        }
                                        </xhtml:ul>
Mathias Goebel's avatar
Mathias Goebel committed
108
109
110
111
112
113
114
115
116
117
118
119
                                case 5 return
                                                if( not($tei//profileDesc/textDesc/derivation/*) ) then "Keine" else
                                                <ul>{for $type in distinct-values($tei//profileDesc/textDesc/derivation/linkGrp/link/string(@type))
                                                    return
                                                        <li>{switch($type)
                                                            case 'mentioned' return 'Im Notizbuch von Fontane genannte Quellen'
                                                            case 'ascertained' return 'Ermittelte Quellen'
                                                            case 'ascertained' return 'Weitere ermittelte Quellen'
                                                            default return 'TODO @type'
                                                        } <ul> {for $link in $tei//profileDesc/textDesc/derivation/linkGrp/link[@type = $type]
                                                            let $target := substring-after(substring-after($link/@target, ' '), ':')
                                                            let $litVZ := doc('/db/sade-projects/textgrid/data/xml/data/25547.xml')/tei:TEI
Mathias Goebel's avatar
Mathias Goebel committed
120
121
                                                            let $page := substring-after($link/@target, "_") => substring-before("_")
                                                            return
122
123
124
125
126
127
128
                                                                if(starts-with($link/@target, "http://textgridrep.org/"))
                                                                then
                                                                    <xhtml:li>
                                                                    <xhtml:a href="literaturvz.html?id={$target}">{ $litVZ//bibl[@xml:id = $target]//abbr/text() => replace("\.$", "")}</xhtml:a>;
                                                                    {if($link/@resp) then (' vgl. ', <xhtml:a href="literaturvz.html?id={substring-after($link/@resp, ':')}">{$litVZ//bibl[@xml:id = substring-after($link/@resp, ':')]//abbr/text()}</xhtml:a>, '.') else ()}
                                                                    </xhtml:li>
                                                                else
Mathias Goebel's avatar
Mathias Goebel committed
129
                                                                <xhtml:li>
130
                                                                    <xhtml:a href="literaturvz.html?id={$target}">{ $litVZ//bibl[@xml:id = $target]//abbr/text() => replace("\.$", "")}</xhtml:a>;
Mathias Goebel's avatar
Mathias Goebel committed
131
                                                                    <xhtml:a href="edition.html?id={request:get-parameter("id", "")}&amp;page={$page}&amp;target={substring-before($link/@target, " ") => substring-after("#")}">Blatt {$page}</xhtml:a>.
132
133
                                                                {if($link/@resp) then (' [Vgl. ', <xhtml:a href="literaturvz.html?id={substring-after($link/@resp, ':')}">{$litVZ//bibl[@xml:id = substring-after($link/@resp, ':')]//abbr/text()}</xhtml:a>, '.]') else ()}
                                                                </xhtml:li>
Mathias Goebel's avatar
Mathias Goebel committed
134
135
136
137
138
                                                        } </ul></li>}</ul>
                                case 6
                                    return
                                        if($tei//msPart/*)
                                        then    <div>
139
                                                    <div>{
Mathias Goebel's avatar
Mathias Goebel committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
                                                        switch(count($tei//msPart))
                                                            case 1 return "Eine"
                                                            case 2 return "Zwei"
                                                            case 3 return "Drei"
                                                            case 4 return "Vier"
                                                            case 5 return "Fünf"
                                                            case 6 return "Sechs"
                                                            case 7 return "Sieben"
                                                            case 8 return "Acht"
                                                            case 9 return "Neun"
                                                            default return "Übersetzung von Zahl nur bis 9."}
                                                    </div>
                                                    <ul>
                                                        {   for $msPart in $tei//tei:msPart[tei:msIdentifier][tei:ab]
                                                            return
155
                                                                <li>{local:textref($msPart/ab//text())}</li>
Mathias Goebel's avatar
Mathias Goebel committed
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
                                                        }
                                                    </ul>

                                                </div>
                                        else "Keine"
                                case 7 return
                                                let $lis := (<li>{if (exists($tei/profileDesc/creation/date[@type = 'authorial']//text()))then () else attribute class {'OutOfOrder'} }Fontanes Angabe: {if(exists($tei/profileDesc/creation/date[@type = 'authorial']//text())) then $tei/profileDesc/creation/date[@type = 'authorial']//text() else 'Keine'}</li>,
                                                            <li>{if (exists($tei/profileDesc/creation/date[@type = 'Friedrich_Fontane']//text()))then () else attribute class {'OutOfOrder'} }Friedrich Fontanes Angabe: {if(exists($tei/profileDesc/creation/date[@type = 'Friedrich_Fontane']//text())) then $tei/profileDesc/creation/date[@type = 'Friedrich_Fontane']//text() else 'Keine'}</li>,
                                                            <li>{if (exists($tei/profileDesc/creation/date[@type = 'editorial']//text()))then () else attribute class {'OutOfOrder'} }Ermittelt: {if(exists($tei/profileDesc/creation/date[@type = 'editorial']//text())) then $tei/profileDesc/creation/date[@type = 'editorial']//text() else 'Keine'}</li>)
                                                return
                                                <ul>{$lis}</ul>
                                case 8 return <ul>{for $lang in $tei/profileDesc/langUsage/language return <li>{$lang/text()}</li>}</ul>
                                case 9 return <ul>{for $hand in $tei/profileDesc/handNotes return
                                    switch($hand/number(@n))
                                        case 1 return <li>Zeitgenössische Schreiberhände &#x2013; Autor <ul>{for $h in $hand/handNote return <li>{$h//text()}</li>}</ul></li>
                                        case 2 return <li>Zeitgenössische Schreiberhände &#x2013; Schreiber<ul>{for $h in $hand/handNote return <li>{$h//text()}</li>}</ul></li>
                                        case 3 return <li>Postume Schreiberhände &#x2013; Schreiber<ul>{for $h in $hand/handNote return <li>{$h//text()}</li>}</ul></li>
                                        case 4 return <li>Postume Schreiberhände &#x2013; Archivare<ul>{for $h in $hand/handNote return <li>{$h//text()}</li>}</ul></li>
                                        case 5 return <li>Zeitgenössiche und postume Schreiberhände &#x2013; Stempel<ul>{for $h in $hand/handNote return <li>{$h//text()}</li>}</ul></li>
                                        case 6 return <li>Zeitgenössische und postume Schreiberhände &#x2013; Drucke<ul>{for $h in $hand/handNote return <li>{$h//text()}</li>}</ul></li>
                                    default return ()
                                 }</ul>
                                case 10 return <ul>{for $hand in $tei/profileDesc/handNotes return
                                    switch($hand/number(@n))
                                        case 7 return for $h in $hand/handNote return <li>{$h//text()}</li>
                                        case 8 return (<hr/>, for $h in $hand/handNote return <li>{$h//text()}</li>)
                                    default return ()
                                 }</ul>
                                case 11 return <ul>{for $hand in $tei/profileDesc/handNotes return
                                    switch($hand/number(@n))
                                        case 9
                                        return
                                            for $h in $hand/handNote
                                            return
                                                <li>
                                                    {switch($h/string(@script))
                                                        case 'clean' return 'Reinschriftlich'
                                                        case 'standard' return 'Standard'
                                                        case 'hasty' return "Unruhig"
                                                        case 'angular' return "Gezackt"
                                                        default return 'TODO'}<ul> <li>{$h//text()}</li> </ul></li>
                                    default return ()
                                 }</ul>
199
                                case 12 return <ul>{for $item in $tei//sourceDesc/msDesc/physDesc/typeDesc/ab return <li>{local:textref($item//text()[not(parent::tei:hi)])}</li>}</ul>
Mathias Goebel's avatar
Mathias Goebel committed
200
201
202
203
204
205
206
                                case 13 return $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/layoutDesc/layout/text()
                                case 14 return $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/extent/measure/@quantity || ' ' || (switch(string($tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/extent/measure/@unit)) case 'leaf' return 'Blatt' default return 'TODO: Einheit übersetzen!!!')
                                case 15 return <ul>{for $item in $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/extent/dimensions return <li>{switch(string($item/@type)) case 'leaf' return 'Blatt' case 'binding' return 'Einband' default return 'TODO: @type übersetzen!!!'} <ul>{for $i in $item/* return <li>{switch($i/local-name()) case 'width' return 'Breite' case 'height' return 'Höhe' case 'depth' return 'Tiefe' default return 'TODO: local-name() übersetzen!!!'}&#x20;{string($i/@quantity)} {string($i/@unit)}</li>}</ul></li>}</ul>
                                case 16 return <p>{$tei/fileDesc/sourceDesc/msDesc/physDesc/bindingDesc//text()}</p>
(:                                case 17 return (if($tei/fileDesc/sourceDesc/msDesc/physDesc/accMat/text()) then $tei/fileDesc/sourceDesc/msDesc/physDesc/accMat/text() else 'Keine'):)
                                case 17 return  let $types := distinct-values( $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab/hi/string(.) )
                                                let $out :=
207
208
209
210
211
212
213
214
215
216
217
218
                                                    <ul>
                                                        {for $item in $types
                                                        where $item != 'Vakat-Seiten:' and $item != 'Blattfragmente:'
                                                        return
                                                            <li>{replace($item, ":", "")}
                                                                <ul>{local:textref(
                                                                        $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab[hi/text() = $item]//text()[not(parent::tei:hi)]
                                                                        )}
                                                                </ul>
                                                            </li> }

                                                    </ul>
Mathias Goebel's avatar
Mathias Goebel committed
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
                                                return if(not($out//li)) then 'Keine' else $out
                                case 18 return <ul>{for $item in $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab[hi/string(.) = 'Blattfragmente:']
                                                    let $empty := starts-with(($item//text())[2], ' Keine')
                                                    return
                                                        <li class="{if( $empty = true() ) then 'OutOfOrder' else '' }">
                                                            {if( $empty = true() )
                                                            then substring-after(($item//text())[2], 'Keine ')
                                                            else tokenize(($item//text())[2], ';\s')[2]  }
                                                            <ul>
                                                                { if( $empty = true() )
                                                                then <li>Keine</li>
                                                                else
                                                                    <li>{tokenize(string-join($item//text()[not(parent::tei:hi)][not(parent::tei:ref)]), ';\s')[1]};
                                                                        {for $text in ($item//text()[not(parent::tei:hi)])[position() != 1]
                                                                        return local:textref($text)}</li>
                                                                }</ul></li>
                                                }</ul>
                                case 19 return <ul>{for $item in $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/support/ab[hi/string(.) = 'Vakat-Seiten:'] return <li>{$item//text()[not(parent::tei:hi)]}</li>}</ul>
                                case 20 return <ul>{for $item in $tei/fileDesc/sourceDesc/msDesc/physDesc/decoDesc/ab[hi/string(.) = 'Skizzen:'] return <li>{for $text in $item//text()[not(parent::tei:hi)] return local:textref($text)}</li>}</ul>
                                case 21 return <ul>{for $item in $tei/fileDesc/sourceDesc/msDesc/physDesc/additions/ab[hi/string(.) = 'Stempel:'] return <li>{for $text in $item//text()[not(parent::tei:hi)] return local:textref($text)}</li>}</ul>
                                case 22 return $tei/fileDesc/sourceDesc/msDesc/physDesc/objectDesc/supportDesc/foliation//text()
240
                                case 23 return
Mathias Goebel's avatar
minor    
Mathias Goebel committed
241
242
243
244
                                        let $items := $tei//sourceDesc/msDesc/physDesc/handDesc/ab
                                        (: Do we find only entries with "Keine" in our sequence of Elements? :)
                                        let $count := count($items//ab[contains(., "Keine")]) eq count($items//ab)
                                        return
245
246
247
248
                                        <xhtml:ul>
                                            {if(not($count))
                                            then
                                                for $item in $items//ab
Mathias Goebel's avatar
Mathias Goebel committed
249
                                                where not($item[contains(., "Keine")])
250
                                                return
Mathias Goebel's avatar
Mathias Goebel committed
251
252
                                                    <xhtml:li>{local:textref($item//text()[not( exists(parent::tei:hi) )])}</xhtml:li>
                                                (:soem:)
253
254
255
256
                                            else
                                                <xhtml:li>Keine</xhtml:li>
                                            }
                                        </xhtml:ul>
Mathias Goebel's avatar
Mathias Goebel committed
257
258
                                default return "error"
                return
259
260
261
262
263
264
265
266
267
                <tr class="teiHeaderRow{if(replace(string-join($content), "\s", "") = 'Keine') then ' OutOfOrder' else ''}">
                    <th scope="row">
                      <span class="rowNum">
                        <a class="headerLink" href="ueberblickskommentar.html?{request:get-query-string()}#r{$pos}">
                          <i class="fa fa-link"></i>
                        </a>{$pos}
                      </span>
                      <span class="anchor" id="r{$pos}"/>
                    </th>
Mathias Goebel's avatar
Mathias Goebel committed
268
269
270
271
272
273
274
                    <td><span title="{$path[$pos]}">{$title}</span></td>
                    <td>{$content}</td>
                </tr>

return
    <div class="container">
    {   for $ab in $tei//abstract/ab
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
        return
            <xhtml:p class="intro">{
                for $node in $ab/node()
                return
                    typeswitch ( $node )
                    case element( tei:bibl ) return
                        let $target := $node/tei:ptr/@target => substring-after("lit:")
                        let $bibl := collection("/db/sade-projects")//@xml:id[.=$target]/parent::node()
                        let $citRange := $node/tei:citedRange/text()
                        return
                            (<xhtml:a href="literaturvz.html?id={$target}">{ $bibl//tei:abbr/text() }</xhtml:a>,
                              if( $citRange ) then " "||$citRange else ()
                            )
                    default return
                        $node


            }</xhtml:p>
Mathias Goebel's avatar
Mathias Goebel committed
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
    }
    {if(doc-available($docpath)) then
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Information</th>
                    <th>Beschreibung</th>
                </tr>
            </thead>
            <tbody>
                {$items}
            </tbody>
        </table>
    else <xhtml:div>The requested document is not available.</xhtml:div> }
    </div>
};

declare function local:textref($text as node()*) as node()*{
for $item in $text return
    if($item/parent::tei:ref)
    then
        let $target := string($item/parent::tei:ref/@target),
            $id := if(matches($target, '^#[A-E]\d\d_'))
                    then substring-after($target, '#')
                    else (),
            $page :=    if($id)
Mathias Goebel's avatar
Mathias Goebel committed
320
                        then $text/ancestor::tei:TEI//tei:surface[.//@xml:id = $id]/string(@n)
Mathias Goebel's avatar
Mathias Goebel committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
                        else tokenize($target, "'")[2],
            $doc := request:get-parameter('id', ''),
            $hl := if($id) then '#'||$id else (),
            $link := 'edition.html?id='||$doc||'&amp;page='||$page||$hl
    return
        <xhtml:a href="{$link}">{$item}</xhtml:a>
    else if($item/parent::tei:rs) then
            let $ref := $item/parent::tei:rs/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}">{$item}</xhtml:a>
    else $item
};