forked from EpiDoc/Stylesheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fo-teilb.xsl
337 lines (311 loc) · 20.6 KB
/
fo-teilb.xsl
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
<!-- $Id$ --><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="http://www.tei-c.org/ns/1.0" xmlns:EDF="http://epidoc.sourceforge.net/ns/functions" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#all" version="2.0">
<!-- Actual display and increment calculation found in teilb.xsl -->
<xsl:import href="teilb.xsl"/>
<xsl:template match="t:lb">
<xsl:param name="parm-edn-structure" tunnel="yes" required="no"/>
<xsl:param name="parm-edition-type" tunnel="yes" required="no"/>
<xsl:param name="parm-leiden-style" tunnel="yes" required="no"/>
<xsl:param name="parm-line-inc" tunnel="yes" required="no"/>
<xsl:param name="parm-verse-lines" tunnel="yes" required="no"/>
<xsl:param name="location"/>
<xsl:choose>
<xsl:when test="ancestor::t:lg and $parm-verse-lines = 'on'">
<xsl:apply-imports/>
<!-- use the particular templates in teilb.xsl -->
</xsl:when>
<xsl:otherwise>
<xsl:variable name="div-loc">
<xsl:for-each select="ancestor::t:div[@type= 'textpart']">
<xsl:value-of select="@n"/>
<xsl:text>-</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="line">
<xsl:if test="@n">
<xsl:value-of select="@n"/>
</xsl:if>
</xsl:variable>
<!-- print hyphen if break=no -->
<xsl:if test="(@break='no' or @type='inWord')">
<xsl:choose>
<!-- *unless* edh web -->
<xsl:when test="$parm-leiden-style='eagletxt'"/>
<!-- *unless* diplomatic edition -->
<xsl:when test="$parm-edition-type='diplomatic'"/>
<!-- *or unless* the lb is first in its ancestor div -->
<xsl:when test="generate-id(self::t:lb) = generate-id(ancestor::t:div[1]/t:*[child::t:lb][1]/t:lb[1])"/>
<xsl:when test="$parm-leiden-style = 'ddbdp' and ((not(ancestor::*[name() = 'TEI'])) or $location='apparatus')"/>
<!-- *or unless* the second part of an app in ddbdp -->
<xsl:when test="($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch') and (ancestor::t:corr or ancestor::t:reg or ancestor::t:rdg or ancestor::t:del[parent::t:subst])"/>
<!-- *unless* previous line ends with space / g / supplied[reason=lost] -->
<!-- in which case the hyphen will be inserted before the space/g r final ']' of supplied
(tested by EDF:f-wwrap in functions.xsl, which is called by teisupplied.xsl, teig.xsl and teispace.xsl) -->
<xsl:when test="preceding-sibling::node()[1][local-name() = 'space' or local-name() = 'g' or (local-name()='supplied' and @reason='lost') or (normalize-space(.)='' and preceding-sibling::node()[1][local-name() = 'space' or local-name() = 'g' or (local-name()='supplied' and @reason='lost')])]"/>
<!-- *or unless* this break is accompanied by a paragraphos mark -->
<!-- in which case the hypen will be inserted before the paragraphos by code in htm-teimilestone.xsl -->
<xsl:when test="preceding-sibling::node()[not(self::text() and normalize-space(self::text())='')][1]/self::t:milestone[@rend='paragraphos']"/>
<xsl:otherwise>
<xsl:text>-</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:choose>
<xsl:when test="$parm-leiden-style=('edh-itx','edh-names')">
<xsl:variable name="cur_anc" select="generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])"/>
<xsl:if test="preceding::t:lb[1][generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])=$cur_anc]">
<xsl:choose>
<xsl:when test="$parm-leiden-style='edh-names' and not(@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName)">
<xsl:comment><xsl:text> </xsl:text></xsl:comment>
</xsl:when>
<xsl:when test="$parm-leiden-style=('edh-names')"/>
<xsl:when test="@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName">
<xsl:comment><xsl:text>/</xsl:text></xsl:comment>
</xsl:when>
<xsl:otherwise>
<xsl:comment><xsl:text> / </xsl:text></xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:when test="$parm-leiden-style='eagletxt'">
<xsl:variable name="cur_anc" select="generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])"/>
<xsl:if test="preceding::t:lb[1][generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])=$cur_anc]">
<xsl:choose>
<xsl:when test="not(@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName)">
<xsl:comment><xsl:text> / </xsl:text></xsl:comment>
</xsl:when>
<xsl:when test="@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName">
<xsl:comment><xsl:text>/</xsl:text></xsl:comment>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- print arrows right of line if R2L or explicitly L2R -->
<!-- arrows after final line handled in htm-teiab.xsl -->
<xsl:if test="not($parm-leiden-style=('ddbdp','sammelbuch')) and not(position() = 1) and preceding::t:lb[1][@rend='left-to-right']">
<xsl:text> →</xsl:text>
</xsl:if>
<xsl:if test="not($parm-leiden-style=('ddbdp','sammelbuch')) and not(position() = 1) and preceding::t:lb[1][@rend='right-to-left']">
<xsl:text> ←</xsl:text>
</xsl:if>
<xsl:choose>
<!-- replaced test using generate-id() with 'is' -->
<xsl:when test="self::t:lb is ancestor::t:div[1]/t:*[child::t:lb][1]/t:lb[1]">
<fo:inline>
<xsl:comment>0</xsl:comment>
</fo:inline>
<!-- for the first lb in a div, create an empty anchor instead of a line-break -->
</xsl:when>
<xsl:when test="($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch') and (ancestor::t:sic or ancestor::t:reg or ancestor::t:rdg or ancestor::t:del[ancestor::t:choice]) or ancestor::t:del[@rend='corrected'][parent::t:subst]">
<xsl:choose>
<xsl:when test="@break='no' or @type='inWord'">
<xsl:comment><xsl:text>|</xsl:text></xsl:comment>
</xsl:when>
<xsl:otherwise>
<xsl:comment><xsl:text> | </xsl:text></xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$parm-leiden-style = 'ddbdp' and ((not(ancestor::*[name() = 'TEI'])) or $location='apparatus')">
<xsl:choose>
<xsl:when test="@break='no' or @type='inWord'">
<xsl:comment><xsl:text>|</xsl:text></xsl:comment>
</xsl:when>
<xsl:otherwise>
<xsl:comment><xsl:text> | </xsl:text></xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:block/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$location = 'apparatus'"/>
<xsl:when test="not(number(@n)) and ($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch')">
<!-- non-numerical line-nos always printed in DDbDP -->
<xsl:comment><xsl:call-template name="margin-num"/></xsl:comment>
</xsl:when>
<xsl:when test="number(@n) and @n mod number($parm-line-inc) = 0 and not(@n = 0) and not(following::t:*[1][local-name() = 'gap' or local-name()='space'][@unit = 'line'] and ($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch'))">
<!-- prints line-nos divisible by stated increment, unless zero
and unless it is a gap line or vacat in DDbDP -->
<xsl:comment><xsl:call-template name="margin-num"/></xsl:comment>
</xsl:when>
<xsl:when test="$parm-leiden-style = 'ddbdp' and preceding-sibling::t:*[1][local-name()='gap'][@unit = 'line']">
<!-- always print line-no after gap line in ddbdp -->
<xsl:comment><xsl:call-template name="margin-num"/></xsl:comment>
</xsl:when>
<xsl:when test="$parm-leiden-style = 'ddbdp' and following::t:lb[1][ancestor::t:reg[following-sibling::t:orig[not(descendant::t:lb)]]]">
<!-- always print line-no when broken orig in line, in ddbdp -->
<xsl:comment><xsl:call-template name="margin-num"/></xsl:comment>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="t:lb" mode="linenumber">
<xsl:param name="parm-edn-structure" tunnel="yes" required="no"/>
<xsl:param name="parm-edition-type" tunnel="yes" required="no"/>
<xsl:param name="parm-leiden-style" tunnel="yes" required="no"/>
<xsl:param name="parm-line-inc" tunnel="yes" required="no"/>
<xsl:param name="parm-verse-lines" tunnel="yes" required="no"/>
<xsl:param name="location"/>
<xsl:choose>
<xsl:when test="ancestor::t:lg and $parm-verse-lines = 'on'">
<xsl:apply-imports/>
<!-- use the particular templates in teilb.xsl -->
</xsl:when>
<xsl:otherwise>
<xsl:variable name="div-loc">
<xsl:for-each select="ancestor::t:div[@type= 'textpart']">
<xsl:value-of select="@n"/>
<xsl:text>-</xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="line">
<xsl:if test="@n">
<xsl:value-of select="@n"/>
</xsl:if>
</xsl:variable>
<!-- print hyphen if break=no -->
<xsl:if test="(@break='no' or @type='inWord')">
<xsl:choose>
<!-- *unless* edh web -->
<xsl:when test="$parm-leiden-style='eagletxt'"/>
<!-- *unless* diplomatic edition -->
<xsl:when test="$parm-edition-type='diplomatic'"/>
<!-- *or unless* the lb is first in its ancestor div -->
<xsl:when test="generate-id(self::t:lb) = generate-id(ancestor::t:div[1]/t:*[child::t:lb][1]/t:lb[1])"/>
<xsl:when test="$parm-leiden-style = 'ddbdp' and ((not(ancestor::*[name() = 'TEI'])) or $location='apparatus')"/>
<!-- *or unless* the second part of an app in ddbdp -->
<xsl:when test="($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch') and (ancestor::t:corr or ancestor::t:reg or ancestor::t:rdg or ancestor::t:del[parent::t:subst])"/>
<!-- *unless* previous line ends with space / g / supplied[reason=lost] -->
<!-- in which case the hyphen will be inserted before the space/g r final ']' of supplied
(tested by EDF:f-wwrap in functions.xsl, which is called by teisupplied.xsl, teig.xsl and teispace.xsl) -->
<xsl:when test="preceding-sibling::node()[1][local-name() = 'space' or local-name() = 'g' or (local-name()='supplied' and @reason='lost') or (normalize-space(.)='' and preceding-sibling::node()[1][local-name() = 'space' or local-name() = 'g' or (local-name()='supplied' and @reason='lost')])]"/>
<!-- *or unless* this break is accompanied by a paragraphos mark -->
<!-- in which case the hypen will be inserted before the paragraphos by code in htm-teimilestone.xsl -->
<xsl:when test="preceding-sibling::node()[not(self::text() and normalize-space(self::text())='')][1]/self::t:milestone[@rend='paragraphos']"/>
<xsl:otherwise>
<xsl:text>-</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:choose>
<xsl:when test="$parm-leiden-style=('edh-itx','edh-names')">
<xsl:variable name="cur_anc" select="generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])"/>
<xsl:if test="preceding::t:lb[1][generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])=$cur_anc]">
<xsl:choose>
<xsl:when test="$parm-leiden-style='edh-names' and not(@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName)">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$parm-leiden-style=('edh-names')"/>
<xsl:when test="@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName">
<xsl:text>/</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> / </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:when test="$parm-leiden-style='eagletxt'">
<xsl:variable name="cur_anc" select="generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])"/>
<xsl:if test="preceding::t:lb[1][generate-id(ancestor::node()[local-name()='lg' or local-name()='ab'])=$cur_anc]">
<xsl:choose>
<xsl:when test="not(@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName)">
<xsl:text> / </xsl:text>
</xsl:when>
<xsl:when test="@break='no' or ancestor::t:w | ancestor::t:name | ancestor::t:placeName | ancestor::t:geogName">
<xsl:text>/</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- print arrows right of line if R2L or explicitly L2R -->
<!-- arrows after final line handled in htm-teiab.xsl -->
<xsl:if test="not($parm-leiden-style=('ddbdp','sammelbuch')) and not(position() = 1) and preceding::t:lb[1][@rend='left-to-right']">
<xsl:text> →</xsl:text>
</xsl:if>
<xsl:if test="not($parm-leiden-style=('ddbdp','sammelbuch')) and not(position() = 1) and preceding::t:lb[1][@rend='right-to-left']">
<xsl:text> ←</xsl:text>
</xsl:if>
<xsl:choose>
<!-- replaced test using generate-id() with 'is' -->
<xsl:when test="self::t:lb is ancestor::t:div[1]/t:*[child::t:lb][1]/t:lb[1]">
<fo:inline>
<xsl:comment>0</xsl:comment>
</fo:inline>
<!-- for the first lb in a div, create an empty anchor instead of a line-break -->
</xsl:when>
<xsl:when test="($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch') and (ancestor::t:sic or ancestor::t:reg or ancestor::t:rdg or ancestor::t:del[ancestor::t:choice]) or ancestor::t:del[@rend='corrected'][parent::t:subst]">
<xsl:choose>
<xsl:when test="@break='no' or @type='inWord'">
<xsl:text>|</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> | </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$parm-leiden-style = 'ddbdp' and ((not(ancestor::*[name() = 'TEI'])) or $location='apparatus')">
<xsl:choose>
<xsl:when test="@break='no' or @type='inWord'">
<xsl:text>|</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> | </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:block><fo:leader/></fo:block>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$location = 'apparatus'"/>
<xsl:when test="not(number(@n)) and ($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch')">
<!-- non-numerical line-nos always printed in DDbDP -->
<xsl:call-template name="margin-num"/>
</xsl:when>
<xsl:when test="number(@n) and @n mod number($parm-line-inc) = 0 and not(@n = 0) and not(following::t:*[1][local-name() = 'gap' or local-name()='space'][@unit = 'line'] and ($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch'))">
<!-- prints line-nos divisible by stated increment, unless zero
and unless it is a gap line or vacat in DDbDP -->
<xsl:call-template name="margin-num"/>
</xsl:when>
<xsl:when test="$parm-leiden-style = 'ddbdp' and preceding-sibling::t:*[1][local-name()='gap'][@unit = 'line']">
<!-- always print line-no after gap line in ddbdp -->
<xsl:call-template name="margin-num"/>
</xsl:when>
<xsl:when test="$parm-leiden-style = 'ddbdp' and following::t:lb[1][ancestor::t:reg[following-sibling::t:orig[not(descendant::t:lb)]]]">
<!-- always print line-no when broken orig in line, in ddbdp -->
<xsl:call-template name="margin-num"/>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="margin-num">
<xsl:param name="parm-leiden-style" tunnel="yes" required="no"/>
<xsl:choose>
<!-- don't print marginal line number inside tags that are relegated to the apparatus (ddbdp) -->
<xsl:when test="$parm-leiden-style = 'eagletxt'"/>
<xsl:when test="($parm-leiden-style = 'ddbdp' or $parm-leiden-style = 'sammelbuch') and (ancestor::t:sic or ancestor::t:reg or ancestor::t:rdg or ancestor::t:del[ancestor::t:choice]) or ancestor::t:del[@rend='corrected'][parent::t:subst]"/>
<xsl:otherwise>
<fo:inline>
<xsl:value-of select="@n"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>