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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
|
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:xd="http://www.pnp-software.com/XSLTdoc"
version="1.0">
<xsl:include href="indent.xsl"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="stylesheet-entry_svnid">$Id$</xsl:variable>
<!-- I am fully aware of introducing some project-specific features into the P5 mode,
but let this stuff reside here for a while until we come up with a clean way to
import project-dependent overrides from the individual project directories... -PB 13-apr-09-->
<!-- TEI entry specific templates -->
<xsl:template match="tei:entry">
<xsl:apply-templates select="tei:form"/>
<!-- force form before gramGrp -->
<xsl:apply-templates select="tei:gramGrp"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="tei:sense | tei:note"/>
</xsl:template>
<!--Headword description FORM and GRAMGRP -->
<xsl:template match="tei:form">
<xsl:variable name="paren"
select="count(child::tei:orth) and (count(parent::tei:form) = 1 or @type='infl')"/>
<!-- parenthesized if nested or (ad hoc) if @type="infl" -->
<!-- further adhockishness (I'm duly ashamed): you'd better check if the <orth> is really there, because you may be
looking at nested <form>s; a rewrite is needed here -->
<xsl:if test="$paren">
<xsl:text> (</xsl:text>
</xsl:if>
<!-- mandatory entry > form > orth -->
<xsl:apply-templates select="tei:usg | tei:lbl"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
<!-- added to handle usg info in nested <form>s -->
<xsl:for-each select="tei:orth">
<xsl:choose>
<!-- values from the TEI Guidelines -->
<xsl:when test="count(@extent)=0 or @extent='full'">
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="@extent='pref'">
<xsl:value-of select="concat(.,'-')"/>
</xsl:when>
<xsl:when test="@extent='suff'">
<xsl:value-of select="concat('-',.)"/>
</xsl:when>
<xsl:when test="@extent='part'">
<xsl:value-of select="concat('-',.,'-')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="tei:pron"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
<!-- then, if nested, gramGrp or gram infos... -->
<xsl:apply-templates select=" tei:gramGrp"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="tei:form"/>
<xsl:if test="following-sibling::tei:form and following-sibling::tei:form[1][not(@type='infl')]">
<xsl:text>, </xsl:text>
<!-- cosmetics: no comma before parens -->
</xsl:if>
<xsl:if test="$paren">
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:template>
<!-- can't see when this template may be active; see above for enhancement (pref, suff), if necessary -->
<xsl:template match="tei:orth">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="tei:pron">
<xsl:value-of select="concat(' /',.,'/')"/>
<!--<xsl:text> /</xsl:text><xsl:apply-templates/><xsl:text>/</xsl:text>-->
</xsl:template>
<!-- allow for empty <pos/>; make it a condition for the presence of angled brackets, too
the weird "(self::gramGrp or count(tei:pos/text())"
means "you're either P4 or <pos> in P5 is non-empty"
-->
<xsl:template match="tei:gramGrp">
<xsl:variable name="bracket"
select="count(ancestor::tei:gramGrp)=0 and (count(tei:pos/text()) or count(tei:*[local-name() != 'pos']))"
/>
<xsl:if test="$bracket">
<xsl:text> <</xsl:text>
</xsl:if>
<xsl:for-each
select="tei:pos[text()] | tei:subc | tei:num | tei:number | tei:gen | tei:gramGrp | tei:iType | tei:gram | tei:case">
<xsl:apply-templates select="."/>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:if test="$bracket">
<xsl:text>></xsl:text>
</xsl:if>
<!-- <xr> elements are not allowed inside <form> or <gramGrp>, so reach out and grab them... -->
<xsl:if
test="count(preceding-sibling::tei:xr[@type='plural-form' or @type='imp-form' or
@type='past-form' or @type='infl-form'])">
<xsl:text> </xsl:text>
<xsl:apply-templates
select="preceding-sibling::tei:xr[@type='plural-form' or @type='imp-form' or
@type='past-form' or @type='infl-form']"
/>
</xsl:if>
<!-- horribly project-specific, will be overridden by project-specific imports later on;
OTOH, we might make this a project feature, too, if there is a need -->
<xsl:if test="preceding-sibling::tei:form/@type='N'">
<xsl:text> [sg=pl]</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="tei:gram[@type='cl-agr']">
<xsl:value-of select="concat('agr: ',.)"/>
</xsl:template>
<!-- senses -->
<xsl:template match="tei:sense">
<xsl:variable name="prec_senses">
<xsl:choose>
<xsl:when test="not(preceding-sibling::tei:sense)">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(preceding-sibling::tei:sense)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="pref">
<xsl:choose>
<xsl:when test="@n">
<xsl:value-of select="concat(@n,'. ')"/>
</xsl:when>
<xsl:when test="number($prec_senses) > 0 or following-sibling::tei:sense">
<xsl:value-of select="concat(position(),'. ')"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="number($prec_senses) > 0">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:value-of select="concat(' ',$pref)"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="tei:cit"><!--cit can be @trans, @example, (@colloc) and simple cit (for idiomatic expression)-->
<xsl:choose>
<xsl:when test="@type ='trans'">
<!-- <xsl:if test="preceding-sibling::tei:cit[@type='trans']"><xsl:text> ◊ </xsl:text></xsl:if> -->
<xsl:if test="not(preceding-sibling::tei:cit[@type='trans']) and parent::tei:cit"><xsl:text> - </xsl:text></xsl:if>
<xsl:if test="preceding-sibling::tei:cit[@type='trans']"><xsl:text>, </xsl:text></xsl:if>
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="@type ='example'">
<xsl:text>
 </xsl:text>
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="@type ='colloc'">
<xsl:text> (</xsl:text>
<xsl:apply-templates/>
<xsl:text>) </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:quote">
<xsl:choose>
<xsl:when test="parent::tei:cit[@type='example']">
<xsl:value-of select="concat('"',.,'" ')"/>
</xsl:when><!--
<xsl:when test="parent::tei:cit[@type='trans'][parent::tei:cit]">
<xsl:value-of select="concat(' - ',.,' ')"/>
</xsl:when>-->
<xsl:when test="preceding-sibling::tei:quote"> <!-- parent::tei:cit[@type='trans'] and -->
<xsl:value-of select="', '"/>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template><!---->
<xsl:template match="tei:usg">
<xsl:text> [</xsl:text>
<xsl:value-of select="."/>
<xsl:text>] </xsl:text>
</xsl:template>
<xsl:template match="tei:def">
<xsl:variable name="stuff">
<xsl:apply-templates select="*|text()"/>
</xsl:variable>
<!-- first question: am I abused? Do I hold a translation equivalent
within a <sense>, or am I a real definition within a <cit>? -->
<xsl:choose>
<xsl:when test="parent::tei:sense">
<xsl:variable name="separator">
<xsl:choose>
<xsl:when test="preceding-sibling::tei:def">
<xsl:value-of select="'; '"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' '"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($separator,$stuff)"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="format">
<xsl:with-param name="txt" select="normalize-space($stuff)"/>
<xsl:with-param name="width" select="75"/>
<xsl:with-param name="start" select="4"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:xr">
<xsl:choose>
<xsl:when test="count(@rend) and @rend='as-is'">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="not(@type) or @type='cf'">
<xsl:text>
 See also: </xsl:text>
<xsl:apply-templates select="tei:ref"/>
<!-- <xsl:text>
</xsl:text> -->
</xsl:when>
<xsl:when test="@type='syn'">
<xsl:text>
 </xsl:text>
<xsl:choose>
<xsl:when test="count(tei:ref) > 1">
<xsl:text>Synonyms: </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Synonym: </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="tei:ref"/>
<!-- <xsl:text>
</xsl:text> -->
</xsl:when>
<xsl:when test="@type='ant'">
<xsl:text>
 </xsl:text>
<xsl:choose>
<xsl:when test="count(tei:ref) > 1">
<xsl:text>Antonyms: </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Antonym: </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="tei:ref"/>
<!-- <xsl:text>
</xsl:text> -->
</xsl:when>
<xsl:when test="@type='infl-base'">
<!-- inflectional base -->
<xsl:text>
 Inflection of: </xsl:text>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:when test="@type='deriv-base'">
<!-- derivational/compound base -->
<xsl:text>
 Derived from: </xsl:text>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>
</xsl:text>
</xsl:when>
<!-- the <xr>s below are positioned inline -->
<xsl:when test="@type='imp-form'">
<!-- imperative -->
<xsl:text>(imp: </xsl:text>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="@type='plural-form'">
<!-- plural -->
<xsl:text>(pl: </xsl:text>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="@type='past-form'">
<!-- past -->
<xsl:text>(past: </xsl:text>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="@type='infl-form'">
<!-- general inflections, e.g. past/pprt/fut -->
<xsl:text>(</xsl:text>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- unknown type: print the value and set it on a separate line -->
<xsl:text>
 </xsl:text>
<xsl:value-of select="concat(@type,': ')"/>
<xsl:apply-templates select="tei:ref"/>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:ref">
<xsl:if test="preceding-sibling::*[1][self::tei:ref]">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="ancestor::tei:teiHeader or ancestor::tei:front">
<xsl:value-of select="concat(.,' [',@target,']')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('{',.,'}')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:entry//tei:p">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="tei:note[@type='editor']" priority="1"/>
<xsl:template match="tei:entry//tei:note">
<xsl:variable name="stuff">
<xsl:apply-templates/>
</xsl:variable>
<xsl:variable name="spc">
<xsl:choose>
<xsl:when test="(count(preceding-sibling::node())=0) or @rend='noindent'">
<xsl:value-of select="''"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' '"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="count(@*)=0">
<xsl:value-of select="concat('
 Note: ',$stuff)"/>
</xsl:when>
<xsl:when test="@resp='translator'">
<xsl:text>
 Entry edited by: </xsl:text>
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:when>
<!-- a subset of values from the TEI Guidelines -->
<xsl:when
test="@type='lbl' or @type='dom' or @type='obj' or @type='subj' or @type='hint' or @type='num' or @type='geo' or @type='syn' or @type='colloc'">
<xsl:value-of select="concat($spc,'(',.,')')"/>
</xsl:when>
<xsl:when test="@type='gram'">
<xsl:text>
</xsl:text>
<xsl:call-template name="format">
<xsl:with-param name="txt" select="concat(' (',normalize-space($stuff),')')"/>
<!-- select="concat(' Note (gram.): ',normalize-space($stuff))"-->
<xsl:with-param name="width" select="75"/>
<xsl:with-param name="start" select="1"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@type='usage'">
<xsl:text>
</xsl:text>
<xsl:call-template name="format">
<xsl:with-param name="txt" select="concat(' (',normalize-space($stuff),')')"/>
<!-- select="concat(' Usage: ',normalize-space($stuff))"-->
<xsl:with-param name="width" select="75"/>
<xsl:with-param name="start" select="1"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@type='def'">
<xsl:text>
</xsl:text>
<xsl:call-template name="format">
<!--<xsl:with-param name="txt" select="concat(' Def.: ',normalize-space())"/>-->
<xsl:with-param name="txt" select="concat(' ',normalize-space($stuff))"/>
<xsl:with-param name="width" select="75"/>
<xsl:with-param name="start" select="1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($spc,'(',$stuff,')')"/>
<xsl:text>
</xsl:text>
</xsl:otherwise>
<!--<xsl:when test="text()">
<xsl:text>
 Note: </xsl:text>
<xsl:value-of select="text()"/>
</xsl:when>-->
</xsl:choose>
</xsl:template>
<xsl:template match="tei:q">
<xsl:value-of select="concat('"',.,'"')"/>
</xsl:template>
<xsl:template match="tei:lbl">
<xsl:text> (</xsl:text>
<xsl:value-of select="."/>
<xsl:text>) </xsl:text>
</xsl:template>
<xsl:template match="tei:author">
<xsl:value-of select="concat(.,' ')"/>
</xsl:template>
<xsl:template match=" tei:pos | tei:subc | tei:num | tei:number | tei:gen | tei:iType | tei:gram | tei:case">
<xsl:choose>
<xsl:when test="not(parent::tei:gramGrp)">
<xsl:value-of select="concat(' ',.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|