-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.xsl
More file actions
314 lines (289 loc) · 13.4 KB
/
Copy pathstyle.xsl
File metadata and controls
314 lines (289 loc) · 13.4 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei">
<xsl:output method="html" indent="yes" encoding="UTF-8"/>
<xsl:param name="pageId" />
<xsl:param name="editionType" select="'diplomatic'"/>
<xsl:template match="/">
<div class="manuscript-page-sheet">
<div class="tei-transcription">
<xsl:apply-templates select="//tei:pb[@facs=$pageId] | //*[local-name()='pb'][@facs=$pageId]"/>
</div>
</div>
</xsl:template>
<xsl:template match="tei:pb | *[local-name()='pb']">
<xsl:variable name="myFacs" select="@facs"/>
<xsl:apply-templates select="following-sibling::node()[
preceding-sibling::*[local-name()='pb'][1]/@facs = $pageId
and not(local-name(.) = 'pb')]" />
</xsl:template>
<xsl:template match="tei:div | tei:div[@type='transcription-container'] | tei:div[@type='column-left-2r'] | tei:div[@type='column-right-2r']">
<xsl:choose>
<xsl:when test="$editionType = 'critical'">
<div class="critical-block-wrapper {@type}">
<xsl:apply-templates/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="{@type}">
<xsl:apply-templates/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:p">
<xsl:choose>
<xsl:when test="$editionType = 'critical'">
<p>
<xsl:choose>
<xsl:when test=".//tei:figure">
<xsl:variable name="fig" select=".//tei:figure[1]"/>
<xsl:attribute name="class">critical-linear-text critical-figure-caption</xsl:attribute>
<xsl:if test="$fig/tei:graphic/@url">
<xsl:attribute name="data-region">
<xsl:variable name="cleanId" select="translate($pageId, '#', '')"/>
<xsl:variable name="afterId" select="substring-after($fig/tei:graphic/@url, concat($cleanId, '/'))"/>
<xsl:choose>
<xsl:when test="contains($afterId, '/')">
<xsl:value-of select="substring-before($afterId, '/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$afterId"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">critical-linear-text</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@xml:id='p-3v-del-1'">
<xsl:apply-templates select=".//tei:del"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</p>
</xsl:when>
<xsl:otherwise>
<p class="tei-lines">
<xsl:if test="@xml:id">
<xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:figure">
<xsl:choose>
<xsl:when test="(ancestor::tei:p or ancestor::tei:seg) and not(@place)">
</xsl:when>
<xsl:when test="$editionType = 'critical'">
<div class="critical-figure-caption">
<xsl:if test="@xml:id">
<xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute>
</xsl:if>
<xsl:if test="tei:graphic/@url">
<xsl:attribute name="data-region">
<xsl:variable name="cleanId" select="translate($pageId, '#', '')"/>
<xsl:variable name="afterId" select="substring-after(tei:graphic/@url, concat($cleanId, '/'))"/>
<xsl:choose>
<xsl:when test="contains($afterId, '/')">
<xsl:value-of select="substring-before($afterId, '/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$afterId"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="tei:figDesc/node() | tei:note"/>
</div>
</xsl:when>
<xsl:otherwise>
<div class="leonardo-figure">
<xsl:if test="@xml:id">
<xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute>
</xsl:if>
<xsl:attribute name="class"><xsl:value-of select="concat('leonardo-figure ', @place)"/></xsl:attribute>
<img src="{tei:graphic/@url}" alt="{tei:figDesc}" />
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:choice">
<xsl:choose>
<xsl:when test="$editionType = 'critical'">
<span class="reg">
<xsl:choose>
<xsl:when test="tei:reg">
<xsl:apply-templates select="tei:reg"/>
</xsl:when>
<xsl:when test="tei:expan/tei:reg">
<xsl:apply-templates select="tei:expan/tei:reg"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="tei:expan | tei:abbr | tei:orig"/>
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:when>
<xsl:otherwise>
<span class="abbr">
<xsl:if test="tei:expan">
<xsl:attribute name="title">
<xsl:value-of select="concat('Expansion: ', tei:expan)"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="tei:abbr | tei:orig"/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:reg">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="tei:note[@type='critical']">
<xsl:if test="$editionType = 'critical'">
<sup class="note-ref"><xsl:value-of select="@n"/></sup>
</xsl:if>
</xsl:template>
<xsl:template match="tei:supplied">
<xsl:if test="$editionType = 'critical'">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="tei:del">
<xsl:choose>
<xsl:when test="$editionType = 'critical'">
<xsl:if test="ancestor::tei:p[@xml:id='p-3v-del-1' or @xml:id='p-3v-del-2']">
<xsl:apply-templates/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<del>
<xsl:attribute name="title">
<xsl:text>Deleted by the author: </xsl:text>
<xsl:choose>
<xsl:when test=".//tei:orig | .//tei:abbr">
<xsl:for-each select=".//tei:orig | .//tei:abbr">
<xsl:value-of select="normalize-space(.)"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(.)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</del>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:seg[@hand='#other-hand']">
<xsl:choose>
<xsl:when test="$editionType = 'critical'">
<div class="critical-figure-caption other-hand-block">
<xsl:if test=".//tei:figure/tei:graphic/@url">
<xsl:attribute name="data-region">
<xsl:variable name="cleanId" select="translate($pageId, '#', '')"/>
<xsl:variable name="afterId" select="substring-after(.//tei:figure/tei:graphic/@url, concat($cleanId, '/'))"/>
<xsl:choose>
<xsl:when test="contains($afterId, '/')">
<xsl:value-of select="substring-before($afterId, '/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$afterId"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="text() | tei:handShift"/>
</div>
</xsl:when>
<xsl:otherwise>
<span class="other-hand" title="Other hand">
<xsl:apply-templates/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:add">
<xsl:choose>
<xsl:when test="$editionType = 'diplomatic'">
<span class="tei-add add-{@place}"><xsl:apply-templates/></span>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:lb">
<xsl:choose>
<xsl:when test="$editionType = 'diplomatic'">
<span class="lb-line"></span> </xsl:when>
<xsl:when test="ancestor::tei:figDesc">
<br/>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:pc">
<xsl:choose>
<xsl:when test="@type = 'diplomatic'">
<xsl:if test="$editionType = 'diplomatic'">
<span class="punct-diplomatic">
<xsl:apply-templates/>
</span>
</xsl:if>
</xsl:when>
<xsl:when test="@type = 'critical'">
<xsl:if test="$editionType = 'critical'">
<span class="punct-critical">
<xsl:apply-templates/>
</span>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:label">
<xsl:if test="$editionType = 'critical'">
<div class="tei-label">
<xsl:apply-templates/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="tei:seg">
<span>
<xsl:choose>
<xsl:when test="$editionType = 'critical' and tei:figure">
<xsl:variable name="fig" select="tei:figure[1]"/>
<xsl:attribute name="class"><xsl:value-of select="concat(@class, ' critical-figure-caption')"/></xsl:attribute>
<xsl:if test="$fig/tei:graphic/@url">
<xsl:attribute name="data-region">
<xsl:variable name="cleanId" select="translate($pageId, '#', '')"/>
<xsl:value-of select="substring-before(substring-after($fig/tei:graphic/@url, concat($cleanId, '/')), '/')"/>
</xsl:attribute>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="tei:subst"><span class="subst"><xsl:apply-templates/></span></xsl:template>
<xsl:template match="tei:metamark"><span class="tei-metamark"><xsl:apply-templates/><span class="caret">^</span></span></xsl:template>
</xsl:stylesheet>