gfl-indexer.xslt 46 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
Dennis Neumann's avatar
Dennis Neumann committed
2

Dennis Neumann's avatar
Dennis Neumann committed
3
4
<!-- 

Dennis Neumann's avatar
Dennis Neumann committed
5
This script produces two types of Solr XML documents, representing letters and individual pages of those letters.
Dennis Neumann's avatar
Dennis Neumann committed
6

Dennis Neumann's avatar
Dennis Neumann committed
7
8
9
10
11
12
13
The letter documents contain many metadata fields and two text fields. The metadata fields are
values that are copied from the TEI files. The text fields are described next.

Field 'fulltext'

This is just plain text copied from the complete TEI file. Line breaks and page beginnings are
transformed to whitespace. This field can be useful for searching or for generating highlighting snippets. 
Dennis Neumann's avatar
Dennis Neumann committed
14
15
16

Field 'fulltext_html'

Dennis Neumann's avatar
Dennis Neumann committed
17
18
19
20
21
22
This field  contains the HTML representation of the text of a TEI file (e. g. a Goethe letter).
A letter that consists of several pages is split on-the-fly into those pages.
However, the pages are all kept in this one field. The templates that are used here are the same
as the ones for the individual page documents (see below).

The letters are composed of different parts, for example 'opener', 'closer', 'salute'.
Dennis Neumann's avatar
Dennis Neumann committed
23
24
25
All those parts are represented here as <div>'s with the corresponding CSS classes.
The frontend viewer must decide how to format those parts and present them to the user.

Dennis Neumann's avatar
Dennis Neumann committed
26
The original TEI files contain mark-up for many in-text parts, like dates, names, underlined words, etc.
Dennis Neumann's avatar
Dennis Neumann committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Most of these are also transformed to <div>'s with their own CSS classes.
Although the in-text parts are by nature inline elements, we use here <div>'s and not <span>'s.
The reason is that Solr seems to have problems when highlighting fields that contain <span>'s
by sometimes producing corrupt HTML.
By using <div>'s, we avoid this problem.
In the frontend, these <div>'s must be set to 'display: inline'.

Some other in-text parts are transformed to special HTML elements.
For example, superscripted text is marked as <sup>, because HTML offers the appropriate element.

The project is still continuing and new TEI files are being produced.
That's why there might be new elements in the future that cannot be handled yet in this script.
The text of such TEI elements is enclosed in HTML elements of class 'unknown-element'.
Furthermore, a warning message is generated that contains data of the first occurrence of such a new element.


Dennis Neumann's avatar
Dennis Neumann committed
43
44
45
46
The second kind of documents that are produced are page documents.
The resulting pages are in the HTML format.
As the TEI file is processed, the TEI XML structure is split into pages using 
the page beginning elements (<pb/>).
Dennis Neumann's avatar
Dennis Neumann committed
47
Refer to comments in the code to understand the used algorithm.
Dennis Neumann's avatar
Dennis Neumann committed
48

49
-->
Dennis Neumann's avatar
Dennis Neumann committed
50

Dennis Neumann's avatar
Dennis Neumann committed
51
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
52
   xpath-default-namespace="http://www.tei-c.org/ns/1.0" xmlns:gfl="http://sub.gfl.de"
bettin5's avatar
bettin5 committed
53
54
   xmlns:xs="http://www.w3.org/2001/XMLSchema" 
   xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="gfl saxon xs"
bettin5's avatar
bettin5 committed
55
   xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
jerome's avatar
jerome committed
56
57
   xmlns:marc="http://www.loc.gov/MARC21/slim"
   xmlns:img="http://whatever">
58

Dennis Neumann's avatar
Dennis Neumann committed
59
   <xsl:output method="xml" indent="yes" saxon:suppress-indentation="div" />
Dennis Neumann's avatar
Dennis Neumann committed
60
   <xsl:strip-space elements="*" />
61
   <xsl:preserve-space elements="msIdentifier bibl p" />
62
63

   <xsl:template match="/">
64
65
66
67
      <xsl:apply-templates select="TEI" />
   </xsl:template>

   <xsl:template match="TEI">
68
      <add>
jerome's avatar
jerome committed
69
         <doc>    
jerome's avatar
jerome committed
70
            <xsl:apply-templates select="teiHeader|text" />
Dennis Neumann's avatar
Dennis Neumann committed
71
72
73
74
75
            <xsl:for-each select="distinct-values(//@xml:lang)">
               <field name="language">
                  <xsl:value-of select="." />
               </field>
            </xsl:for-each>
jerome's avatar
jerome committed
76
            
77
            <xsl:apply-templates select="facsimile" />
jerome's avatar
jerome committed
78
            <xsl:for-each select="distinct-values(//name/@ref)">
jerome's avatar
jerome committed
79
               <xsl:if test=". != 'gnd:_' and starts-with(., 'gnd:') ">
jerome's avatar
jerome committed
80
81
82
               <field name="entitys_in_documents">
                  <xsl:value-of select="."/>
               </field>
jerome's avatar
jerome committed
83
               </xsl:if>
jerome's avatar
jerome committed
84
            </xsl:for-each>
jerome's avatar
jerome committed
85
         </doc>
jerome's avatar
jerome committed
86
         <xsl:apply-templates select="//body/listBibl" /> 
87
         <xsl:apply-templates select="//name/@ref"/>
88
         <xsl:apply-templates select="text" mode="page_splitting" />
bettin5's avatar
bettin5 committed
89
      </add>
90
   </xsl:template>
bettin5's avatar
bettin5 committed
91
   
92
   <xsl:template match="name/@ref">
jerome's avatar
jerome committed
93
      <xsl:if test=". != 'gnd:_' and ./parent::name/text() and ./parent::name/@type and starts-with(., 'gnd:') ">
bettin5's avatar
bettin5 committed
94
         <doc>
bettin5's avatar
bettin5 committed
95
96
            <field name="entity_name">
               <xsl:value-of select="./parent::name/normalize-space()"/> 
97
            </field>    
bettin5's avatar
bettin5 committed
98
99
100
101
102
            <field name ="doctype">
               <xsl:value-of select="./parent::name/@type"/>
            </field>
            <field name="id">  
               <xsl:value-of select="."/>
bettin5's avatar
bettin5 committed
103
104
            </field>
            <xsl:variable name="gnd_number">
105
               <xsl:value-of select="normalize-space(substring-after(., 'gnd:'))"/>
bettin5's avatar
bettin5 committed
106
107
            </xsl:variable>
            <xsl:variable name="uri_path">
108
               <xsl:value-of select="concat('https://d-nb.info/gnd/', $gnd_number, '/about/marcxml')"/>
bettin5's avatar
bettin5 committed
109
            </xsl:variable>
bettin5's avatar
bettin5 committed
110
111
112
113
114
            <xsl:choose>
               <xsl:when test="doc-available($uri_path)">
                  <xsl:apply-templates select="doc($uri_path)/marc:record" />
               </xsl:when>
            </xsl:choose>
bettin5's avatar
bettin5 committed
115
116
117
118
         </doc>
      </xsl:if>
   </xsl:template>
   
119
   <!-- scraping the gnd database for meta data the result is marc21 with works with numbers as identifyer -->
bettin5's avatar
bettin5 committed
120
121
122
123
124
   <xsl:template match="marc:record">
      <xsl:choose>
         <xsl:when test="marc:datafield[@tag='100']">
            <field name="mostly_use_name">  
               <xsl:value-of  select="marc:datafield[@tag='100']/marc:subfield[@code='a']"/>
125
126
127
128
               <xsl:if test="marc:datafield[@tag='100']/marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>
                  <xsl:value-of  select="marc:datafield[@tag='100']/marc:subfield[@code='g']"/>
               </xsl:if>
bettin5's avatar
bettin5 committed
129
130
131
132
133
            </field>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag='110']">
            <field name="mostly_use_name">  
               <xsl:value-of  select="marc:datafield[@tag='110']/marc:subfield[@code='a']"/>
134
135
136
137
               <xsl:if test="marc:datafield[@tag='110']/marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>
                  <xsl:value-of  select="marc:datafield[@tag='110']/marc:subfield[@code='g']"/>
               </xsl:if>
bettin5's avatar
bettin5 committed
138
139
140
141
142
            </field>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag='111']">
            <field name="mostly_use_name">  
               <xsl:value-of  select="marc:datafield[@tag='111']/marc:subfield[@code='a']"/>
143
144
145
146
               <xsl:if test="marc:datafield[@tag='111']/marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>
                  <xsl:value-of  select="marc:datafield[@tag='111']/marc:subfield[@code='g']"/>
               </xsl:if>
bettin5's avatar
bettin5 committed
147
148
149
150
151
            </field>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag='130']">
            <field name="mostly_use_name">  
               <xsl:value-of  select="marc:datafield[@tag='130']/marc:subfield[@code='a']"/>
152
153
154
155
               <xsl:if test="marc:datafield[@tag='130']/marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>
                  <xsl:value-of  select="marc:datafield[@tag='130']/marc:subfield[@code='g']"/>
               </xsl:if>
bettin5's avatar
bettin5 committed
156
157
158
159
            </field>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag='150']">
            <field name="mostly_use_name">  
160
161
162
163
164
               <xsl:value-of  select="marc:datafield[@tag='150']/marc:subfield[@code='a']"/>
               <xsl:if test="marc:datafield[@tag='150']/marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>
                  <xsl:value-of  select="marc:datafield[@tag='150']/marc:subfield[@code='g']"/>
               </xsl:if>
bettin5's avatar
bettin5 committed
165
166
167
168
            </field>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag='151']">
            <field name="mostly_use_name">  
169
170
171
172
173
               <xsl:value-of  select="marc:datafield[@tag='151']/marc:subfield[@code='a']"/>
               <xsl:if test="marc:datafield[@tag='151']/marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>
                  <xsl:value-of  select="marc:datafield[@tag='151']/marc:subfield[@code='g']"/>
               </xsl:if>
bettin5's avatar
bettin5 committed
174
175
176
177
178
179
            </field>
         </xsl:when>
      </xsl:choose> 
      <xsl:for-each select="marc:datafield[@tag='400']">
      <field name="alternatively_name">  
         <xsl:value-of select="marc:subfield[@code='a']"/>
180
181
182
183
184
185
         <xsl:choose>
         <xsl:when test="marc:subfield[@code='c']">
            <xsl:text> </xsl:text>   
            <xsl:value-of select="marc:subfield[@code='c']"/>
         </xsl:when>
         </xsl:choose>
bettin5's avatar
bettin5 committed
186
187
188
189
190
      </field>
      </xsl:for-each>
      <xsl:for-each select="marc:datafield[@tag='410']">
         <field name="alternatively_name">  
            <xsl:value-of select="marc:subfield[@code='a']"/>
191
192
193
194
195
196
197
198
199
200
            <xsl:choose>
               <xsl:when test="marc:subfield[@code='b']">
                  <xsl:text> </xsl:text>   
                  <xsl:value-of select="marc:subfield[@code='b']"/>
               </xsl:when>
               <xsl:when test="marc:subfield[@code='g']">
                  <xsl:text> </xsl:text>   
                  <xsl:value-of select="marc:subfield[@code='g']"/>
               </xsl:when>
            </xsl:choose>
bettin5's avatar
bettin5 committed
201
202
203
204
205
206
207
208
209
210
211
212
213
214
         </field>
      </xsl:for-each>
      <xsl:for-each select="marc:datafield[@tag='430']">
         <field name="alternatively_name">  
            <xsl:value-of select="marc:subfield[@code='a']"/><xsl:text></xsl:text>   
            <xsl:value-of select="marc:subfield[@code='g']"/><xsl:text></xsl:text>   
            <xsl:value-of select="marc:subfield[@code='n']"/>
         </field>
      </xsl:for-each>
      <xsl:for-each select="marc:datafield[@tag='451']">
         <field name="alternatively_name">  
            <xsl:value-of select="marc:subfield[@code='a']"/>
         </field>
      </xsl:for-each>
215
      <xsl:for-each select="marc:datafield[@tag='034']"> 
bettin5's avatar
bettin5 committed
216
217
218
219
220
221
222
223
224
225
226
227
228
229
         <field name="west_cordinate">  
            <xsl:value-of select="marc:subfield[@code='e']"/>
         </field>
         <field name="east_cordinate">  
            <xsl:value-of select="marc:subfield[@code='e']"/>
         </field>
         <field name="north_cordinate">  
            <xsl:value-of select="marc:subfield[@code='f']"/>
         </field>
         <field name="south_cordinate">  
            <xsl:value-of select="marc:subfield[@code='g']"/>
         </field>
      </xsl:for-each>
   </xsl:template>
jerome's avatar
jerome committed
230
231
   
   <!--Doctype Literature scraped from body/listBibl for each bibl tag in body;  -->
jerome's avatar
jerome committed
232
   <xsl:template match="//body/listBibl">
bettin5's avatar
bettin5 committed
233
         <xsl:for-each select="bibl">
bettin5's avatar
bettin5 committed
234
            <doc>
bettin5's avatar
bettin5 committed
235
               <field name="id"> 
236
                  <xsl:value-of select="replace(./@xml:id , '_', ' ')"/>
bettin5's avatar
bettin5 committed
237
               </field>
238
               <field name="doctype">literature</field>
bettin5's avatar
bettin5 committed
239
                  <xsl:for-each select="relatedItem">
240
241
242
243
244
245
246
247
248
249
250
                    <xsl:choose>
                       <xsl:when test="ref/@target = 'https://_' or ref/@target = '' or ref/@target = '_'">
                          <field name="uri"/>
                       </xsl:when>
                       <xsl:otherwise>
                          <field name="uri">
                             <xsl:value-of select="ref/@target"/>
                          </field>
                       </xsl:otherwise>
                    </xsl:choose>         
                  </xsl:for-each>     
bettin5's avatar
bettin5 committed
251
               <xsl:for-each select="author">
252
                  <field name="literature_author"> 
jerome's avatar
jerome committed
253
                     <xsl:value-of select="./normalize-space()"/>
bettin5's avatar
bettin5 committed
254
255
256
257
258
259
260
                  </field>
               </xsl:for-each>
               <xsl:for-each select="editor">
                  <field name="editor"> 
                     <xsl:value-of select="./normalize-space()"/>
                  </field>
               </xsl:for-each>
jerome's avatar
jerome committed
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
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
320
321
322
323
324
325
326
327
               <!-- TITLE -->
                  <xsl:for-each select="title">
                     <xsl:choose>
                        <xsl:when test="./@type = 'main'">
                           <xsl:choose>
                              <xsl:when test="./@level = 'a'">
                                 <field name="analytic_main_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 'm'">
                                 <field name="monographic_main_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 'j'">
                                 <field name="journal_main_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 's'">
                                 <field name="series_main_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 'u'">
                                 <field name="unpublished_main_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                           </xsl:choose>   
                        </xsl:when>
                        <xsl:when test="./@type = 'sub'">
                           <xsl:choose>
                              <xsl:when test="./@level = 'a'">
                                 <field name="analytic_sub_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 'm'">
                                 <field name="monographic_sub_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 'j'">
                                 <field name="journal_sub_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 's'">
                                 <field name="series_sub_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                              <xsl:when test="./@level = 'u'">
                                 <field name="unpublished_sub_title"> 
                                    <xsl:value-of select="./normalize-space()"/>
                                 </field>
                              </xsl:when>
                           </xsl:choose>   
                        </xsl:when>
                        <xsl:otherwise>
                           <field name="title"> 
                              <xsl:value-of select="./normalize-space()"/>
                           </field>
                        </xsl:otherwise>
                     </xsl:choose>
jerome's avatar
jerome committed
328
                  </xsl:for-each>
329
                   <xsl:for-each select="biblScope">
330
331
332
333
334
335
                      <xsl:if test=".[@unit='volume'and @n] ">
                         <field name="biblScope_volume_n"> 
                            <xsl:value-of select="./normalize-space()"/>
                         </field>
                      </xsl:if>
                      <xsl:if test=".[@unit='volume'] [not(@n)] ">
336
337
338
339
340
341
342
343
344
                        <field name="biblScope_volume"> 
                           <xsl:value-of select="./normalize-space()"/>
                        </field>
                      </xsl:if>
                      <xsl:if test=".[@unit='pages']">
                         <field name="biblScope_pages"> 
                            <xsl:value-of select="./normalize-space()"/>
                         </field>
                      </xsl:if>  
jerome's avatar
jerome committed
345
                </xsl:for-each>  
bettin5's avatar
bettin5 committed
346
347
348
349
350
               <xsl:if test="edition!=''">
                  <field name="edition"> 
                     <xsl:value-of select="edition/normalize-space()"/>
                  </field>
               </xsl:if> 
351
               <xsl:for-each select="pubPlace/name">
bettin5's avatar
bettin5 committed
352
               <field name="pub_place"> 
353
                  <xsl:value-of select="./normalize-space()"/>
jerome's avatar
jerome committed
354
               </field>
355
               </xsl:for-each>
jerome's avatar
jerome committed
356
357
358
359
360
361
362
363
364
365
               <xsl:if test="extent">
                  <field name="extent"> 
                     <xsl:value-of select="extent/normalize-space()"/>
                  </field>
               </xsl:if>
               <xsl:if test="publisher">
                  <field name="publisher">
                     <xsl:value-of select="publisher/normalize-space()"/>
                  </field>               
               </xsl:if>
bettin5's avatar
bettin5 committed
366
               <xsl:if test="date/@type='pub'">
367
                  <field name="lit_pub_date">
jerome's avatar
jerome committed
368
                     <xsl:value-of select="date/normalize-space()"/>
bettin5's avatar
bettin5 committed
369
370
                  </field>
               </xsl:if>
jerome's avatar
jerome committed
371
372
373
374
375
376
377
378
379
               <xsl:if test="idno !='' and idno[@type = 'ISBN']">
                     <field name="ISBN"> 
                        <xsl:value-of select="idno/normalize-space()"/>
                     </field>   
               </xsl:if>
               <xsl:if test="idno !='' and idno[@type = 'ISSN']">
                  <field name="ISSN"> 
                     <xsl:value-of select="idno/normalize-space()"/>
                  </field>   
jerome's avatar
jerome committed
380
               </xsl:if>   
bettin5's avatar
bettin5 committed
381
           </doc>
bettin5's avatar
bettin5 committed
382
383
384
           </xsl:for-each>
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
385

386
387
388
389
   <xsl:template match="text()" mode="text_only">
      <xsl:variable name="currentText" select="replace(., '\s+', ' ')" />
      <xsl:choose>
         <xsl:when test="ends-with(., '-')">
Dennis Neumann's avatar
Dennis Neumann committed
390
391
            <!-- These are cases where one word is divided between two lines. 
            The minus sign is removed here, the line break (<lb/>) is removed in its own template. -->
392
393
394
            <xsl:value-of select="substring($currentText, 1, string-length($currentText)-1)" />
         </xsl:when>
         <xsl:when test="ends-with(., '&#0173;')">
Dennis Neumann's avatar
Dennis Neumann committed
395
396
397
            <!-- A soft hyphen is a convention to mark a hyphen that belongs to the word or is a hyphen on its own.
            For now, it is just replaced by a minus sign. 
            Later, it might be useful to differentiate between word divisions and hyphens. -->
398
399
400
401
402
403
            <xsl:value-of select="replace($currentText, '&#0173;', '-')" />
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$currentText" />
         </xsl:otherwise>
      </xsl:choose>
Dennis Neumann's avatar
Dennis Neumann committed
404
405
406
407
408
   </xsl:template>
   
   <!--###########   Header   #######################-->
   
   <xsl:template match="teiHeader">
Dennis Neumann's avatar
Dennis Neumann committed
409
      <xsl:apply-templates select="fileDesc | profileDesc/textClass" />
Dennis Neumann's avatar
Dennis Neumann committed
410
411
412
413
414
415
416
   </xsl:template>
   
   <xsl:template match="fileDesc">
      <xsl:apply-templates select="titleStmt/title" />
      <xsl:apply-templates select="titleStmt/title[@type='desc']/name" />
      <xsl:apply-templates select="titleStmt/title[@type='desc']/date[@type='orn']" />
      <xsl:apply-templates select="titleStmt/author/name" />
417
      <xsl:apply-templates select="sourceDesc" />
Dennis Neumann's avatar
Dennis Neumann committed
418
      <xsl:apply-templates select="publicationStmt/availability/licence" />
Dennis Neumann's avatar
Dennis Neumann committed
419
420
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
421
422
423
424
   <xsl:template match="profileDesc/textClass">
      <xsl:apply-templates select="keywords/term" />
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
425
   <xsl:template match="title[@type='short']">
Dennis Neumann's avatar
Dennis Neumann committed
426
      <field name="short_title">
Dennis Neumann's avatar
Dennis Neumann committed
427
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
428
429
430
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
431
   <xsl:template match="title[@type='desc']">
Dennis Neumann's avatar
Dennis Neumann committed
432
      <field name="title">
Dennis Neumann's avatar
Dennis Neumann committed
433
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
434
435
436
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
437
   <xsl:template match="title/name[@type='place' and @subtype='orn']">
Dennis Neumann's avatar
Dennis Neumann committed
438
      <field name="origin_place">
Dennis Neumann's avatar
Dennis Neumann committed
439
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
440
441
442
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
443
   <xsl:template match="title/name[@type='place' and @subtype='dtn']">
Dennis Neumann's avatar
Dennis Neumann committed
444
      <field name="destination_place">
Dennis Neumann's avatar
Dennis Neumann committed
445
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
446
447
448
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
449
   <xsl:template match="title/name[@type='person' and @subtype='rcp']">
Dennis Neumann's avatar
Dennis Neumann committed
450
      <field name="recipient">
Dennis Neumann's avatar
Dennis Neumann committed
451
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
452
453
454
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
455
   <xsl:template match="title/date[@type='orn']">
Dennis Neumann's avatar
Dennis Neumann committed
456
457
458
      <field name="origin_date">
         <xsl:value-of select="@when" />
      </field>
459
      <field name="article_pub_date">
460
         <xsl:value-of select="./text()/normalize-space()" />
461
      </field>
Dennis Neumann's avatar
Dennis Neumann committed
462
463
   </xsl:template>

464
   <xsl:template match="author/name">
Dennis Neumann's avatar
Dennis Neumann committed
465
      <field name="author">
Dennis Neumann's avatar
Dennis Neumann committed
466
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
467
468
      </field>
   </xsl:template>
469
470
471
472
473
474
   
   <xsl:template match="sourceDesc">
      <field name="source_description">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
475

Dennis Neumann's avatar
Dennis Neumann committed
476
   <xsl:template match="licence">
Dennis Neumann's avatar
Dennis Neumann committed
477
      <field name="license">
Dennis Neumann's avatar
Dennis Neumann committed
478
479
480
481
         <xsl:value-of select="text()" />
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
482
483
484
485
486
487
488
489
490
491
492
   <xsl:template match="textClass/keywords[@scheme='#gnd']/term">
      <field name="gnd_keyword">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>

   <xsl:template match="textClass/keywords[@scheme='free']/term">
      <field name="free_keyword">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>
jerome's avatar
jerome committed
493
494
495
496
497
498
   
   <xsl:template match="textClass/keywords[@scheme='frei']/term">
      <field name="free_keyword">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
499

bettin5's avatar
bettin5 committed
500
   <!--###################   text/body   ##########################-->  
bettin5's avatar
bettin5 committed
501
502
503
504
505
506
507
508
509
510
511
512

   <xsl:template match="facsimile">
      <xsl:for-each select="./graphic/@xml:id">
         <field name="image_ids"> 
            <xsl:value-of select="."/>
         </field>
      </xsl:for-each>    
      <xsl:for-each select="./graphic/@url">
         <field name="image_urls">
            <xsl:value-of select="."/>
         </field> 
      </xsl:for-each>    
513
514
   </xsl:template> 

Dennis Neumann's avatar
Dennis Neumann committed
515
   <xsl:template match="text">
bettin5's avatar
bettin5 committed
516
517
518
519
520
521
      <xsl:choose>
         <xsl:when test="./@xml:id"> 
            <field name="id">
               <xsl:value-of select="./@xml:id"/>
            </field> 
         </xsl:when>
522
         <xsl:when test="contains(document-uri(/), 'Lit_Archiv/')"> <!-- TODO delte workaround for ids -->
jerome's avatar
jerome committed
523
524
525
526
527
528
529
530
531
532
533
534
            <field name="id">
               <xsl:value-of select="substring-after(substring-before(document-uri(/), '.xml'), 'Lit_Archiv/')" />
            </field> 
         </xsl:when>
         <xsl:when test="contains(document-uri(/), 'Lit_Fbl_Bln/')"> 
            <field name="id">
               <xsl:value-of select="substring-after(substring-before(document-uri(/), '.xml'), 'Lit_Fbl_Bln/')" />
            </field> 
         </xsl:when>
         <xsl:when test="contains(document-uri(/), 'Lit_Bearbeitung/')"> 
            <field name="id">
               <xsl:value-of select="substring-after(substring-before(document-uri(/), '.xml'), 'Lit_Bearbeitung/')" />
535
            </field>
jerome's avatar
jerome committed
536
         </xsl:when>
bettin5's avatar
bettin5 committed
537
538
         <xsl:otherwise>
            <field name="id">
jerome's avatar
jerome committed
539
               <xsl:value-of select="document-uri(/)" /> 
bettin5's avatar
bettin5 committed
540
541
542
            </field> 
         </xsl:otherwise>
      </xsl:choose>
jerome's avatar
jerome committed
543
544

      <xsl:choose> 
545
         <xsl:when test="contains(document-uri(/), 'Lit')"> 
jerome's avatar
jerome committed
546
            <field name="doctype">literature_meta</field>
jerome's avatar
jerome committed
547
         </xsl:when>
jerome's avatar
jerome committed
548

jerome's avatar
jerome committed
549
550
         <xsl:otherwise>
            <field name="doctype">article</field><!--TODO  test!!! -->
jerome's avatar
jerome committed
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
            <field name="number_of_pages">
               <xsl:value-of select="count(//pb)" />
            </field>
            <field name="fulltext">
               <xsl:apply-templates select="body" mode="text_only" />
            </field>
            <field name="fulltext_html">
               <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
               <div class="article">
                  <xsl:variable name="context" select="." />
                  <xsl:for-each-group select="descendant::node()[not(node())]" group-starting-with="pb">
                     <xsl:if test="self::pb">
                        <div class="page">
                           <xsl:call-template name="page-beginning-with-possible-link">
                              <xsl:with-param name="current-pb" select="." />
                           </xsl:call-template>
                           <xsl:apply-templates select="$context/*" mode="page_splitting">
                              <xsl:with-param name="restricted-to" select="current-group()/ancestor-or-self::node()" tunnel="yes" />
                           </xsl:apply-templates>
                        </div>
                     </xsl:if>
                  </xsl:for-each-group>
               </div>
               <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
575
576
            </field>
            <field name="institution">
577
578
579
580
581
582
583
584
585
586
587
588
589
               <xsl:if test="//repository != '' ">
                  <xsl:value-of select="//repository/normalize-space()"/><xsl:text>, </xsl:text>
               </xsl:if>
               <xsl:if test="//institution != '' ">
                  <xsl:value-of select="//institution/normalize-space()"/><xsl:text>, </xsl:text>
               </xsl:if>
               <xsl:if test="//settlement != '' ">
                  <xsl:value-of select="//settlement/normalize-space()"/>
               </xsl:if>
               <xsl:if test="//country != '' ">
                  <xsl:text> (</xsl:text>
                  <xsl:value-of select="//country/normalize-space()"/><xsl:text>)</xsl:text>
               </xsl:if>
590
591
592
593
594
            </field>
            <field name="shelfmark">
               <xsl:value-of select="//idno/normalize-space()"/>
            </field>
            <field name="script_source">
595
596
               <xsl:if test="//supportDesc/extent/text() != '' ">
                  <xsl:value-of select="//supportDesc/extent/text()"/>
597
                  <xsl:text> </xsl:text>
598
599
600
601
602
603
604
605
606
607
608
609
610
               </xsl:if>
               <xsl:if test="//supportDesc/extent/dimensions/height != ''">
                  <xsl:value-of select="//supportDesc/extent/dimensions/height/normalize-space()"/><xsl:text> x </xsl:text>
               </xsl:if>
               <xsl:if test="//supportDesc/extent/dimensions/width != ''">
                  <xsl:value-of select="//supportDesc/extent/dimensions/width/normalize-space()"/><xsl:text> </xsl:text>
               </xsl:if>
               <xsl:if test="//supportDesc/extent/dimensions/@unit">
                  <xsl:value-of select="//supportDesc/extent/dimensions/@unit/normalize-space()"/><xsl:text>. </xsl:text>
               </xsl:if>
               <xsl:if test="//bindingDesc != ''">
                  <xsl:value-of select="//bindingDesc/normalize-space()"/>
               </xsl:if>
611
            </field>
612
            <xsl:for-each select="//handNote">
613
            <field name="writer">
614
               <xsl:value-of select="./normalize-space()"/><xsl:if test="@scope='major'"> – (Grundschicht)</xsl:if>
615
            </field>
616
            </xsl:for-each>
617
618
619
620
621
622
            <field name="reference">
               <xsl:value-of select="//relatedItem[@subtype = 'related']/normalize-space()"/>
            </field>
            <field name="response">
               <xsl:value-of select="//relatedItem[@subtype = 'response']/normalize-space()"/>
            </field>
623
            <xsl:for-each select="//relatedItem[@type = 'letter' and not(@subtype)]">
624
625
626
627
               <field name="related_items">
                  <xsl:value-of select="./ref/normalize-space()"/>
               </field>
            </xsl:for-each>
jerome's avatar
jerome committed
628
629
630
         </xsl:otherwise>
       </xsl:choose>

Dennis Neumann's avatar
Dennis Neumann committed
631
      <xsl:apply-templates select=".//note[@type='com']" />
jerome's avatar
jerome committed
632
     
633
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
634
635
   
   <xsl:template match="body | div" mode="text_only">
636
      <xsl:apply-templates mode="text_only"/>
Dennis Neumann's avatar
Dennis Neumann committed
637
638
   </xsl:template>

639
   <xsl:template match="p | salute | signed  | dateline" mode="text_only"> <!--addrLine -->
Dennis Neumann's avatar
Dennis Neumann committed
640
641
642
      <xsl:apply-templates mode="text_only" />
      <xsl:text> </xsl:text>
   </xsl:template>
643

Dennis Neumann's avatar
Dennis Neumann committed
644
   <xsl:template match="note[@place='end' and not(@type='com')]" mode="text_only">
645
646
647
648
      <xsl:text> </xsl:text>
      <xsl:apply-templates mode="text_only" />
   </xsl:template>

649
   <xsl:template match="lb" mode="text_only">
650
651
652
653
654
655
656
657
658
659
660
661
662
663
      <xsl:variable name="precedingText" select="preceding-sibling::text()[1]" />
      <xsl:choose>
         <xsl:when test="ends-with($precedingText, '-')">
            <!-- Cases where a word is divided between two lines -->
            <!-- no output -->
         </xsl:when>
         <xsl:when test="ends-with($precedingText, '&#0173;') and not(ends-with($precedingText, ' &#0173;'))">
            <!-- Cases where the hyphen belongs to the word (Anna-<lb/>Lena) -->
            <!-- no output -->
         </xsl:when>
         <xsl:otherwise>
            <xsl:text> </xsl:text>
         </xsl:otherwise>
      </xsl:choose>
664
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
665

666
667
668
669
670
671
672
673
   <xsl:template match="pb" mode="text_only">
      <xsl:text> </xsl:text>
   </xsl:template>

   <xsl:template match="space" mode="text_only">
      <xsl:text> </xsl:text>
   </xsl:template>

674
   <xsl:template match="note[@type='com']" mode="text_only">
675
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
676
   
Dennis Neumann's avatar
Dennis Neumann committed
677
678
679
680
681
682
   <xsl:template match="note[@type='com']">
      <field name="note_comment">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
683
   
684
   <!-- %%%%%%%%%%%%% page splitting and HTML generating %%%%%%%%%%%%%%%%%%%%%%% -->
jerome's avatar
jerome committed
685
686
687
688
689
690
   <!-- returns the image path for page-->
   <xsl:function name="img:get_path" as="xs:string">
      <xsl:param name="image_id"/>
      <xsl:param name="context"/>
      <xsl:value-of select="$context/preceding-sibling::facsimile/graphic[@xml:id=$image_id]/@url"/>
   </xsl:function>
691

Dennis Neumann's avatar
Dennis Neumann committed
692
693
694
695
   <!-- Here we start the page splitting algorithm. 
      In general, it groups all elements between two <pb/>'s and creates one page for each such group.
      Note: We use a trick with a tunnel parameter. The templates that are run from here must check 
      if they really should execute or not using that tunnel parameter. -->
696
   <xsl:template match="text" mode="page_splitting">
Dennis Neumann's avatar
Dennis Neumann committed
697
      <!-- We keep the parent of all pages (-> super-parent). -->
698
      <xsl:variable name="context" select="." />
Dennis Neumann's avatar
Dennis Neumann committed
699
700
      <!-- We make groups of only 'small' nodes, like text and <pb/>.
         We need this granularity, because a <pb/> can separate two text nodes to different pages. -->
701
702
703
      <xsl:for-each-group select="descendant::node()[not(node())]" group-starting-with="pb">
         <xsl:if test="self::pb">
            <doc>
Dennis Neumann's avatar
Dennis Neumann committed
704
               <xsl:variable name="pageNumber" select="count(preceding::pb) + 1" />
jerome's avatar
jerome committed
705
            
706
               <field name="id">
Dennis Neumann's avatar
Dennis Neumann committed
707
                  <xsl:value-of select="$context/@xml:id" />
708
709
710
                  <xsl:text>_page</xsl:text>
                  <xsl:value-of select="$pageNumber" />
               </field>
Dennis Neumann's avatar
Dennis Neumann committed
711
               <field name="article_id">
Dennis Neumann's avatar
Dennis Neumann committed
712
                  <xsl:value-of select="$context/@xml:id" />
713
               </field>
714
715
716
               <field name="article_title">
                  <xsl:value-of select="//title[@type='desc']/normalize-space()" />
               </field>
717
               <field name="doctype">page</field>
718
719
720
721
722
723
               <field name="page_number">
                  <xsl:value-of select="$pageNumber" />
               </field>
               <field name="html_page">
                  <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                  <div class="page">
Dennis Neumann's avatar
Dennis Neumann committed
724
725
726
                     <xsl:call-template name="page-beginning-with-possible-link">
                        <xsl:with-param name="current-pb" select="." />
                     </xsl:call-template>
Dennis Neumann's avatar
Dennis Neumann committed
727
                     <!-- We run the templates of all the super-parent's children... -->
728
                     <xsl:apply-templates select="$context/*" mode="page_splitting">
Dennis Neumann's avatar
Dennis Neumann committed
729
730
731
732
733
                        <!-- ..., but we use a trick with a tunnel parameter to restrict the actually executed templates 
                           to the ones relevant for the current page. 
                           We choose the grouped nodes, as well as all their ancestors.
                           We need all the ancestors to construct correctly opened and closed elements 
                           that otherwise would be cut in two by the <pb/>. -->
734
735
736
737
738
                        <xsl:with-param name="restricted-to" select="current-group()/ancestor-or-self::node()" tunnel="yes" />
                     </xsl:apply-templates>
                  </div>
                  <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
               </field>
Dennis Neumann's avatar
Dennis Neumann committed
739
740
741
742
743
               <xsl:for-each select="distinct-values(//@xml:lang)">
                  <field name="language">
                     <xsl:value-of select="." />
                  </field>
               </xsl:for-each>
jerome's avatar
jerome committed
744
               <xsl:variable name="image_id" select="./@facs"/>
745
               <xsl:if test="./@facs">
bettin5's avatar
bettin5 committed
746
                  <field name="image_id"> 
jerome's avatar
jerome committed
747
                     <xsl:value-of select="$image_id"/>
748
                  </field>
jerome's avatar
jerome committed
749
750
               <!-- give me image contains var id -->
               <xsl:variable name="clean_image_id" select="substring($image_id, 2)"/>
751
                  <field name="image_url">
jerome's avatar
jerome committed
752
753
                     <xsl:value-of select="img:get_path($clean_image_id, $context)"/>
                 </field> 
754
755
                  
               </xsl:if>
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
               
               <xsl:variable name="current-pb" select="."/>
               <xsl:variable name="next-pb" select="following::pb[1]"/>
               <xsl:choose>
                  <xsl:when test="$next-pb">
                     <xsl:for-each select="$current-pb/following::name intersect $next-pb/preceding::name">
                        <xsl:call-template name="make-entities-on-page-if-possible">
                           <xsl:with-param name="name" select="."/>
                        </xsl:call-template>
                     </xsl:for-each>
                  </xsl:when>
                  <!-- in this case we are on the last page of the letter -->
                  <xsl:otherwise>
                     <xsl:for-each select="$current-pb/following::name">
                        <xsl:call-template name="make-entities-on-page-if-possible">
                           <xsl:with-param name="name" select="."/>
                        </xsl:call-template>
                     </xsl:for-each>
                  </xsl:otherwise>
               </xsl:choose>
776
777
778
779
780
            </doc>
         </xsl:if>
      </xsl:for-each-group>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
   <xsl:template name="page-beginning-with-possible-link">
      <xsl:param name="current-pb" />
      <div class="page-beginning">
         <xsl:variable name="facsId" select="substring($current-pb/@facs, 2, string-length($current-pb/@facs))" />
         <xsl:variable name="graphicUrl" select="id($facsId)/@url" />
         <xsl:variable name="graphicUrlWithoutJpg">
            <xsl:value-of select="if (ends-with($graphicUrl, '.jpg')) then substring($graphicUrl, 1, string-length($graphicUrl)-4) else $graphicUrl" />
         </xsl:variable>
         <xsl:choose>
            <xsl:when test="$current-pb/@n ne '' and $graphicUrlWithoutJpg">
               <a href="{concat('/', $graphicUrlWithoutJpg)}" target="_blank">
                  <xsl:value-of select="$current-pb/@n" />
               </a>
            </xsl:when>
            <xsl:when test="$current-pb/@n ne ''">
               <xsl:value-of select="$current-pb/@n" />
            </xsl:when>
            <xsl:otherwise>
               <xsl:text> </xsl:text>
            </xsl:otherwise>
         </xsl:choose>
      </div>
   </xsl:template>

805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
   <xsl:template match="pb" mode="page_splitting" />

   <xsl:template match="*" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <xsl:message>
            <xsl:text>Unknown element &lt;</xsl:text>
            <xsl:value-of select="local-name()" />
            <xsl:if test="@rendition">
               <xsl:text> rendition="</xsl:text>
               <xsl:value-of select="@rendition" />
               <xsl:text>"</xsl:text>
            </xsl:if>
            <xsl:if test="@type">
               <xsl:text> type="</xsl:text>
               <xsl:value-of select="@type" />
               <xsl:text>"</xsl:text>
            </xsl:if>
            <xsl:text>&gt; - first occurrence: </xsl:text>
         </xsl:message>
         <span class="unknown-element">
            <xsl:apply-templates mode="page_splitting" />
         </span>
      </xsl:if>
   </xsl:template>

   <xsl:template match="body | div | front" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <xsl:apply-templates mode="page_splitting" />
      </xsl:if>
   </xsl:template>

   <xsl:template match="p | opener | salute | seg | bibl | closer | signed | dateline | date 
839
      | label[not(@rendition)] | choice | abbr | expan | addrLine | postscript" mode="page_splitting">
840
841
842
843
844
845
846
847
848
849
850
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="{local-name(.)}">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="text()" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
         <xsl:variable name="currentText" select="replace(., '\s+', ' ')" />
         <xsl:choose>
            <xsl:when test="ends-with(., '&#0173;')">
               <xsl:value-of select="replace($currentText, '&#0173;', '-')" />
            </xsl:when>
            <xsl:otherwise>
               <xsl:value-of select="$currentText" />
            </xsl:otherwise>
         </xsl:choose>
      </xsl:if>
   </xsl:template>

   <xsl:template match="lb" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <br />
867
868
869
      </xsl:if>
   </xsl:template>

870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
   <xsl:template match="space[@unit='lines']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <xsl:variable name="emptyLines" select="@quantity" />
         <xsl:choose>
            <xsl:when test="$emptyLines castable as xs:integer">
               <xsl:for-each select="1 to $emptyLines">
                  <br />
               </xsl:for-each>
            </xsl:when>
            <xsl:otherwise>
               <br />
            </xsl:otherwise>
         </xsl:choose>
      </xsl:if>
   </xsl:template>

   <xsl:template match="name[@type='place']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="place">
891
892
893
            <xsl:attribute name="id"> 
               <xsl:value-of select="@ref" />
            </xsl:attribute>
894
895
896
897
898
899
900
901
902
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="name[@type='org']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="org">
903
904
905
            <xsl:attribute name="id"> 
               <xsl:value-of select="@ref" />
            </xsl:attribute>
906
907
908
909
910
911
912
913
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="name[@type='person']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
914
915
916
917
918
         <div class="person" >
            <xsl:attribute name="id"> 
               <xsl:value-of select="@ref" />
            </xsl:attribute>
               <xsl:apply-templates mode="page_splitting" />
919
920
921
922
923
924
925
926
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="name[@type='object']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="object">
927
928
929
            <xsl:attribute name="id"> 
               <xsl:value-of select="@ref" />
            </xsl:attribute>
930
931
932
933
934
935
936
937
938
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="rs[@type='person']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="rs-person">
939
940
941
            <xsl:attribute name="id"> 
               <xsl:value-of select="@ref" />
            </xsl:attribute>
942
943
944
945
946
947
948
949
950
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="rs[@type='place']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="rs-place">
951
952
953
            <xsl:attribute name="id"> 
               <xsl:value-of select="@ref" />
            </xsl:attribute>
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="note[@type='com']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="note-comment">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="note[@type='footnote']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="note-footnote">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="note[not(@type)]" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="note">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:underline']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="underline">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:doubleunderline']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="doubleunderline">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:superscript']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <sup>
            <xsl:apply-templates mode="page_splitting" />
         </sup>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:subscript']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <sub>
            <xsl:apply-templates mode="page_splitting" />
         </sub>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:italic']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="italic">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:letterspace']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="letterspace">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>

   <xsl:template match="hi[@rendition='simple:right']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="right">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
   
   <xsl:template match="hi[@rendition='simple:smallcaps']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="smallcaps">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>
   
   <xsl:template match="hi[@rendition='simple:wavyunderline']" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <div class="wavyunderline">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084

   <xsl:template match="ref[@target]" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <a href="{@target}">
            <xsl:apply-templates mode="page_splitting" />
         </a>
      </xsl:if>
   </xsl:template>

   <xsl:template match="head[@rendition] | label[@rendition]" mode="page_splitting">
      <xsl:param name="restricted-to" tunnel="yes" />
      <xsl:if test="exists(. intersect $restricted-to)">
         <xsl:variable name="classNames" select="local-name(), substring-after(@rendition, 'simple:')" />
         <div class="{$classNames}">
            <xsl:apply-templates mode="page_splitting" />
         </div>
      </xsl:if>
   </xsl:template>
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
   
   <xsl:template name="make-entities-on-page-if-possible">
      <xsl:param name="name"/>
      <xsl:variable name="ref" select="$name/@ref"/>
      
      <xsl:if test="$ref != 'gnd:_' and starts-with($ref, 'gnd:') ">
         <field name="entitys_in_page">
            <xsl:value-of select="$ref"/>
         </field>
      </xsl:if>
   </xsl:template>
1096

jerome's avatar
jerome committed
1097
</xsl:stylesheet>