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

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
5
6
   xpath-default-namespace="http://www.tei-c.org/ns/1.0" xmlns:gfl="http://sub.gfl.de"
   xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="gfl saxon xs">

Dennis Neumann's avatar
Dennis Neumann committed
7
   <xsl:output method="xml" indent="yes" saxon:suppress-indentation="div" />
Dennis Neumann's avatar
Dennis Neumann committed
8
   <xsl:strip-space elements="*" />
9
   <xsl:preserve-space elements="msIdentifier bibl p" />
10
11
12
13

   <xsl:template match="/">
      <add>
         <doc>
Dennis Neumann's avatar
Dennis Neumann committed
14
            <xsl:apply-templates select="TEI" />
15
16
17
         </doc>
      </add>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
18

Dennis Neumann's avatar
Dennis Neumann committed
19
20
21
22
23
   <xsl:template match="TEI">
      <xsl:apply-templates select="teiHeader | text" />
   </xsl:template>

   <xsl:template match="text()" mode="#all">
Dennis Neumann's avatar
Dennis Neumann committed
24
      <xsl:value-of select="replace(., '\s+', ' ')" />
Dennis Neumann's avatar
Dennis Neumann committed
25
26
27
28
29
   </xsl:template>
   
   <!--###########   Header   #######################-->
   
   <xsl:template match="teiHeader">
Dennis Neumann's avatar
Dennis Neumann committed
30
      <xsl:apply-templates select="fileDesc | profileDesc/textClass" />
Dennis Neumann's avatar
Dennis Neumann committed
31
32
33
34
35
36
37
   </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" />
38
      <xsl:apply-templates select="sourceDesc" />
Dennis Neumann's avatar
Dennis Neumann committed
39
40
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
41
42
43
44
   <xsl:template match="profileDesc/textClass">
      <xsl:apply-templates select="keywords/term" />
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
45
   <xsl:template match="title[@type='short']">
Dennis Neumann's avatar
Dennis Neumann committed
46
      <field name="short_title">
Dennis Neumann's avatar
Dennis Neumann committed
47
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
48
49
50
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
51
   <xsl:template match="title[@type='desc']">
Dennis Neumann's avatar
Dennis Neumann committed
52
      <field name="title">
Dennis Neumann's avatar
Dennis Neumann committed
53
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
54
55
56
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
57
   <xsl:template match="title/name[@type='place' and @subtype='orn']">
Dennis Neumann's avatar
Dennis Neumann committed
58
      <field name="origin_place">
Dennis Neumann's avatar
Dennis Neumann committed
59
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
60
61
62
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
63
   <xsl:template match="title/name[@type='place' and @subtype='dtn']">
Dennis Neumann's avatar
Dennis Neumann committed
64
      <field name="destination_place">
Dennis Neumann's avatar
Dennis Neumann committed
65
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
66
67
68
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
69
   <xsl:template match="title/name[@type='person' and @subtype='rcp']">
Dennis Neumann's avatar
Dennis Neumann committed
70
      <field name="recipient">
Dennis Neumann's avatar
Dennis Neumann committed
71
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
72
73
74
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
75
   <xsl:template match="title/date[@type='orn']">
Dennis Neumann's avatar
Dennis Neumann committed
76
77
78
79
80
      <field name="origin_date">
         <xsl:value-of select="@when" />
      </field>
   </xsl:template>

Dennis Neumann's avatar
Dennis Neumann committed
81
   <xsl:template match="author/name[@type='person' and @subtype='aut']">
Dennis Neumann's avatar
Dennis Neumann committed
82
      <field name="author">
Dennis Neumann's avatar
Dennis Neumann committed
83
         <xsl:apply-templates mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
84
85
      </field>
   </xsl:template>
86
87
88
89
90
91
   
   <xsl:template match="sourceDesc">
      <field name="source_description">
         <xsl:apply-templates mode="text_only" />
      </field>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
92

Dennis Neumann's avatar
Dennis Neumann committed
93
94
95
96
97
98
99
100
101
102
103
104
105
   <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>


106

Dennis Neumann's avatar
Dennis Neumann committed
107
108
109
110
111
112
113
   <!--###################   text/body   ##########################-->

   <xsl:template match="text">
      <field name="id">
         <xsl:value-of select="@xml:id" />
      </field>
      <field name="fulltext">
Dennis Neumann's avatar
Dennis Neumann committed
114
         <xsl:apply-templates select="body" mode="text_only" />
Dennis Neumann's avatar
Dennis Neumann committed
115
      </field>
Dennis Neumann's avatar
Dennis Neumann committed
116
117
118
119
120
121
122
      <field name="fulltext_html">
         <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
            <div class="article">
               <xsl:apply-templates select="*" mode="html_for_whole_article" />
            </div>
         <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
      </field>
123
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
124
125
126
127
128
129
130
131
132
   
   <xsl:template match="body | div" mode="text_only">
      <xsl:apply-templates select="*" mode="text_only"/>
   </xsl:template>

   <xsl:template match="p" mode="text_only">
      <xsl:apply-templates mode="text_only" />
      <xsl:text> </xsl:text>
   </xsl:template>
133

134
   <xsl:template match="lb" mode="text_only">
135
136
      <xsl:text> </xsl:text>
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
137

138
139
140
141
142
143
144
145
   <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>

146
   <xsl:template match="note[@type='com']" mode="text_only">
147
   </xsl:template>
Dennis Neumann's avatar
Dennis Neumann committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
   
   
   <!-- ++++++++++++ HTML +++++++++++++++++++ -->
   
   <xsl:template match="opener" mode="html_for_whole_article">
      <div class="opener">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>

   <xsl:template match="salute" mode="html_for_whole_article">
      <div class="salute">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>

   <xsl:template match="lb" mode="html_for_whole_article">
      <br />
   </xsl:template>
167

168
169
   <xsl:template match="space[@unit='lines']" mode="html_for_whole_article">
      <xsl:variable name="emptyLines" select="@quantity" />
170
171
172
173
174
175
176
177
178
179
      <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>
180
181
182
   </xsl:template>

   <xsl:template match="p" mode="html_for_whole_article">
Dennis Neumann's avatar
Dennis Neumann committed
183
      <article>
184
         <xsl:apply-templates mode="html_for_whole_article" />
Dennis Neumann's avatar
Dennis Neumann committed
185
      </article>
186
187
188
189
190
191
192
193
   </xsl:template>

   <xsl:template match="name[@type='place']" mode="html_for_whole_article">
      <div class="place">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
Dennis Neumann's avatar
Dennis Neumann committed
194
195
196
197
198
199
200
201
202
203
204
205
   <xsl:template match="name[@type='org']" mode="html_for_whole_article">
      <div class="org">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="name[@type='person']" mode="html_for_whole_article">
      <div class="person">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
206
207
208
209
210
211
   <xsl:template match="name[@type='object']" mode="html_for_whole_article">
      <div class="object">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
212
213
   <xsl:template match="pb" mode="html_for_whole_article">
      <div class="page-break">
Dennis Neumann's avatar
Dennis Neumann committed
214
         <xsl:text>---(neue Seite)---</xsl:text>
215
216
217
      </div>
   </xsl:template>
   
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
   <xsl:template match="seg" mode="html_for_whole_article">
      <div class="seg">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="rs[@type='person']" mode="html_for_whole_article">
      <div class="rs-person">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="note[@type='com']" mode="html_for_whole_article">
      <div class="note-comment">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="hi[@rendition='simple:underline']" mode="html_for_whole_article">
      <div class="underline">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="hi[@rendition='simple:superscript']" mode="html_for_whole_article">
      <div class="superscript">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="hi[@rendition='simple:italic']" mode="html_for_whole_article">
      <div class="italic">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="bibl" mode="html_for_whole_article">
      <div class="bibl">
         <xsl:apply-templates mode="html_for_whole_article" />
      </div>
   </xsl:template>
   
   <xsl:template match="ref[@target]" mode="html_for_whole_article">
      <a href="{@target}">
         <xsl:apply-templates mode="html_for_whole_article" />
      </a>
   </xsl:template>
   
266

Dennis Neumann's avatar
Dennis Neumann committed
267
</xsl:stylesheet>