comparison software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl @ 25:e9fe3186670c default tip

letzter Stand eingecheckt
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 21 May 2013 10:19:32 +0200
parents
children
comparison
equal deleted inserted replaced
23:e845310098ba 25:e9fe3186670c
1 <?xml version="1.0"?>
2 <xsl:stylesheet version="2.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xlink="http://www.w3.org/1999/xlink"
5 xmlns:xs="http://www.w3.org/2001/XMLSchema"
6 xmlns:functx="http://www.functx.com"
7 xmlns:saxon="http://saxon.sf.net/"
8 xmlns:dc="http://purl.org/dc/elements/1.1/"
9 xmlns:dcterms="http://purl.org/dc/terms"
10 xmlns:math="http://www.w3.org/1998/Math/MathML"
11 xmlns:svg="http://www.w3.org/2000/svg"
12 xmlns:xhtml="http://www.w3.org/1999/xhtml"
13 exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
14 >
15
16 <xsl:output method="xhtml" encoding="utf-8"/>
17
18 <xsl:param name="displayWordOptions"></xsl:param>
19 <xsl:param name="echoFiguresDir"></xsl:param>
20 <xsl:param name="echoPageImgDir"></xsl:param>
21
22 <xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
23
24 <xsl:template match="*:TEI">
25 <div>
26 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
27 <xsl:attribute name="class"><xsl:value-of select="'TEI'"/></xsl:attribute>
28 <xsl:apply-templates/>
29 </div>
30 </xsl:template>
31
32 <xsl:template match="*:expan|*:emph|*:q|*:quote|*:reg|*:num">
33 <xsl:element name="span">
34 <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
35 <xsl:copy-of select="@*"/>
36 <xsl:apply-templates/>
37 </xsl:element>
38 </xsl:template>
39
40 <xsl:template match="*:teiHeader">
41 <!-- do nothing -->
42 </xsl:template>
43
44 <xsl:template match="*:text">
45 <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
46 <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
47 <xsl:variable name="textAncestors" select="./ancestor::*:text"/>
48 <xsl:variable name="bottomNotes" select="//*:note[contains(@place, 'foot') or empty(@place)]"/>
49 <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
50 <div>
51 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
52 <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
53 <xsl:apply-templates/>
54 <xsl:if test="$contentStr = '' and empty($figures) and empty($textAncestors)"> <!-- test if div only contains empty nodes but no figures -->
55 <div>
56 <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
57 <xsl:value-of select="'[Empty page]'"/>
58 </div>
59 </xsl:if>
60 <!-- Foot notes -->
61 <xsl:if test="$countBottomNotes > 0">
62 <div class="notes foot">
63 <xsl:for-each select="$bottomNotes">
64 <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
65 <span>
66 <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
67 <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
68 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
69 <span>
70 <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
71 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
72 <xsl:apply-templates/>
73 </span>
74 </span>
75 </xsl:for-each>
76 </div>
77 </xsl:if>
78 </div>
79 <!-- Dictionary -->
80 <xsl:if test="not(empty(//*:entry))">
81 <xsl:for-each select="//*:entry">
82 <xsl:sort select="*:form/*:orth"/>
83 <xsl:variable name="position" select="position()"/>
84 <span class="entry">
85 <xsl:apply-templates select="*:form"/>
86 <xsl:apply-templates select="*:sense"/>
87 <xsl:if test="not(empty(*:figure))">
88 <span class="entryDiv">
89 <span class="bf"><xsl:value-of select="'Figures: '"/></span>
90 <span class="entryDiv">
91 <xsl:for-each select="*:figure">
92 <xsl:variable name="href" select="*:graphic/@url"/>
93 <xsl:variable name="figDesc" select="string(*:figDesc)"/>
94 <xsl:if test="$href != ''">
95 <div class="figure" style="margin-left:10px;">
96 <a href="{$href}"><img alt="Figure: {$figDesc}" src="{$href}" width="200" height="200"/></a>
97 <br/>
98 <xsl:value-of select="'[Figure]: '"/><xsl:apply-templates select="*:head"/>
99 </div>
100 </xsl:if>
101 </xsl:for-each>
102 </span>
103 </span>
104 </xsl:if>
105 <xsl:if test="not(empty(*:xr))">
106 <span class="entryDiv">
107 <span class="bf"><xsl:value-of select="'References: '"/></span>
108 <span class="entryDiv">
109 <xsl:for-each select="*:xr/*:ref">
110 <li><xsl:apply-templates select="."/></li>
111 </xsl:for-each>
112 </span>
113 </span>
114 </xsl:if>
115 </span>
116 </xsl:for-each>
117 </xsl:if>
118 </xsl:template>
119
120 <xsl:template match="*:div">
121 <xsl:if test="node() or normalize-space()"> <!-- test: contains nodes or is not empty -->
122 <div>
123 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
124 <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
125 <xsl:apply-templates/>
126 </div>
127 </xsl:if>
128 </xsl:template>
129
130 <xsl:template match="*:p">
131 <div>
132 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
133 <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
134 <xsl:apply-templates/>
135 </div>
136 </xsl:template>
137
138 <xsl:template match="*:pb">
139 <xsl:variable name="number">
140 <xsl:choose>
141 <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
142 <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
143 </xsl:choose>
144 </xsl:variable>
145 <xsl:variable name="file">
146 <xsl:choose>
147 <xsl:when test="not(empty(@facs))"><xsl:value-of select="@facs"/></xsl:when>
148 <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
149 </xsl:choose>
150 </xsl:variable>
151 <span>
152 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
153 <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
154 <span>
155 <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
156 <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
157 <span>
158 <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
159 <xsl:value-of select="$number"/>
160 </span>
161 </span>
162 </span>
163 </xsl:template>
164
165 <xsl:template match="*:head">
166 <div>
167 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
168 <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
169 <xsl:apply-templates/>
170 </div>
171 </xsl:template>
172
173 <xsl:template match="*:figure">
174 <span class="figure">
175 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
176 <xsl:variable name="url">
177 <xsl:choose>
178 <xsl:when test="not(empty(@facs))"><xsl:value-of select="string(@facs)"/></xsl:when>
179 <xsl:otherwise><xsl:value-of select="string(graphic/@url)"/></xsl:otherwise>
180 </xsl:choose>
181 </xsl:variable>
182 <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $url)"/>
183 <xsl:variable name="digilibUrl">
184 <xsl:choose>
185 <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
186 <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/></xsl:otherwise>
187 </xsl:choose>
188 </xsl:variable>
189 <xsl:variable name="scalerUrl">
190 <xsl:choose>
191 <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
192 <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
193 </xsl:choose>
194 </xsl:variable>
195 <a href="{$digilibUrl}">
196 <img>
197 <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
198 </img>
199 </a>
200 <xsl:if test="not(empty(@number))">
201 <span>
202 <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
203 <span>
204 <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
205 <xsl:value-of select="string(@number)"/>
206 </span>
207 <span>
208 <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
209 <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
210 </span>
211 </span>
212 </xsl:if>
213 <xsl:if test="not(empty(*:head))">
214 <span class="caption">
215 <xsl:for-each select="*:head">
216 <xsl:apply-templates/>
217 </xsl:for-each>
218 </span>
219 </xsl:if>
220 </span>
221 </xsl:template>
222
223 <!-- segmentation -->
224 <xsl:template match="*:seg">
225 <span>
226 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
227 <xsl:choose>
228 <xsl:when test="@rend = 'highlight'">
229 <xsl:attribute name="class"><xsl:value-of select="'seg highlight'"/></xsl:attribute>
230 <xsl:apply-templates/>
231 </xsl:when>
232 <xsl:when test="@rend = 'highlightPoint'">
233 <xsl:attribute name="class"><xsl:value-of select="'seg highlightPoint'"/></xsl:attribute>
234 <xsl:apply-templates/>
235 </xsl:when>
236 <xsl:otherwise>
237 <xsl:attribute name="class"><xsl:value-of select="'seg'"/></xsl:attribute>
238 <xsl:apply-templates/>
239 </xsl:otherwise>
240 </xsl:choose>
241 </span>
242 </xsl:template>
243
244 <!-- choice -->
245 <xsl:template match="*:choice">
246 <span>
247 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
248 <xsl:attribute name="class"><xsl:value-of select="'choice'"/></xsl:attribute>
249 <xsl:if test="not(empty(*:orig))">
250 <xsl:apply-templates select="*:orig"/>
251 </xsl:if>
252 <xsl:if test="not(empty(*:abbr))">
253 <xsl:apply-templates select="*:abbr"/>
254 </xsl:if>
255 <xsl:if test="not(empty(*:am))">
256 <xsl:apply-templates select="*:am"/>
257 </xsl:if>
258 <xsl:if test="not(empty(*:sic))">
259 <xsl:apply-templates select="*:sic"/>
260 </xsl:if>
261 </span>
262 </xsl:template>
263
264 <!-- hi (highlighted) -->
265 <xsl:template match="*:hi">
266 <xsl:choose>
267 <xsl:when test="not(empty(@type)) and @type = 'elem'">
268 <div>
269 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
270 <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
271 <xsl:apply-templates/>
272 </div>
273 </xsl:when>
274 <xsl:when test="not(empty(@type)) and @type != 'elem'">
275 <span>
276 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
277 <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
278 <xsl:apply-templates/>
279 </span>
280 </xsl:when>
281 <xsl:when test="@rend = 'initial'">
282 <span>
283 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
284 <xsl:attribute name="class"><xsl:value-of select="'initial'"/></xsl:attribute>
285 <xsl:apply-templates/>
286 </span>
287 </xsl:when>
288 <xsl:when test="@rend = 'bold'">
289 <span>
290 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
291 <xsl:attribute name="class"><xsl:value-of select="'bf'"/></xsl:attribute>
292 <xsl:apply-templates/>
293 </span>
294 </xsl:when>
295 <xsl:otherwise>
296 <span>
297 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
298 <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
299 <xsl:apply-templates/>
300 </span>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:template>
304
305 <!-- name (of type: place, person, ...) -->
306 <xsl:template match="*:name">
307 <span>
308 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
309 <xsl:choose>
310 <xsl:when test="@type = 'place'">
311 <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
312 <xsl:attribute name="title"><xsl:value-of select="'Place'"/></xsl:attribute>
313 <xsl:apply-templates/>
314 </xsl:when>
315 <xsl:when test="@type = 'person'">
316 <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
317 <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
318 <xsl:apply-templates/>
319 </xsl:when>
320 <xsl:when test="@type = 'org'">
321 <xsl:attribute name="class"><xsl:value-of select="'organization'"/></xsl:attribute>
322 <xsl:attribute name="title"><xsl:value-of select="'Organization'"/></xsl:attribute>
323 <xsl:apply-templates/>
324 </xsl:when>
325 <xsl:otherwise>
326 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
327 <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
328 <xsl:apply-templates/>
329 </xsl:otherwise>
330 </xsl:choose>
331 </span>
332 </xsl:template>
333
334 <!-- place, person, ...) -->
335 <xsl:template match="*:placeName">
336 <span>
337 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
338 <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
339 <xsl:attribute name="title"><xsl:value-of select="concat('Place: ', @type)"/></xsl:attribute>
340 <xsl:apply-templates/>
341 </span>
342 </xsl:template>
343 <xsl:template match="*:persName">
344 <span>
345 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
346 <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
347 <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
348 <xsl:apply-templates/>
349 </span>
350 </xsl:template>
351
352 <!-- term -->
353 <xsl:template match="*:term">
354 <span>
355 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
356 <xsl:attribute name="class"><xsl:value-of select="'term'"/></xsl:attribute>
357 <xsl:attribute name="title"><xsl:value-of select="'Terminology entry'"/></xsl:attribute>
358 <xsl:apply-templates/>
359 </span>
360 </xsl:template>
361
362 <!-- line -->
363 <xsl:template match="*:lg">
364 <div>
365 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
366 <xsl:attribute name="class"><xsl:value-of select="'lg'"/></xsl:attribute>
367 <xsl:apply-templates/>
368 </div>
369 </xsl:template>
370
371 <xsl:template match="*:l">
372 <span>
373 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
374 <xsl:attribute name="class"><xsl:value-of select="'l'"/></xsl:attribute>
375 <xsl:apply-templates/>
376 </span>
377 <br/>
378 </xsl:template>
379
380 <!-- reference: sourounds it by parantheses so that it could be
381 iop from word links within it -->
382 <xsl:template match="*:ref">
383 <xsl:variable name="refPos"><xsl:value-of select="count(./preceding::*:ref) + 1"/></xsl:variable>
384 <span>
385 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
386 <xsl:attribute name="class"><xsl:value-of select="'ref'"/></xsl:attribute>
387 <xsl:if test="not(empty(@target))">
388 <a class="ref">
389 <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
390 <span class="super"><xsl:value-of select="concat('[', $refPos)"/></span>
391 </a>
392 <xsl:value-of select="' '"/>
393 <xsl:apply-templates/>
394 <xsl:value-of select="' '"/>
395 <a class="ref">
396 <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
397 <span class="super"><xsl:value-of select="concat($refPos, ']')"/></span>
398 </a>
399 </xsl:if>
400 <xsl:if test="empty(@target)">
401 <xsl:apply-templates/>
402 </xsl:if>
403 </span>
404 </xsl:template>
405
406 <!-- table -->
407 <xsl:template match="*:table">
408 <table>
409 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
410 <xsl:if test="not(empty(head))">
411 <caption align="top"><xsl:apply-templates select="*:head"/></caption>
412 </xsl:if>
413 <xsl:apply-templates select="*:row"/>
414 </table>
415 </xsl:template>
416
417 <xsl:template match="*:row">
418 <tr>
419 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
420 <xsl:choose>
421 <xsl:when test="@role = 'label'">
422 01002 b
423 ghj565hghj23,b02,0 <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
424 0 <xsl:apply-templates/>
425 bvcxvb4 </xsl:when>
426 <xsl:when test="@role = 'data' or empty(@role)">
427 <xsl:apply-templates/>
428 </xsl:when>
429 <xsl:otherwise>
430 <xsl:apply-templates/>
431 </xsl:otherwise>
432 </xsl:choose>
433 </tr>
434 </xsl:template>
435
436 <xsl:template match="*:cell">
437 <td>
438 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
439 <xsl:choose>
440 <xsl:when test="@role = 'label' and empty(@cols)">
441 <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
442 <xsl:apply-templates/>
443 </xsl:when>
444 <xsl:when test="@role = 'label' and not(empty(@cols))">
445 <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
446 <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
447 <xsl:apply-templates/>
448 </xsl:when>
449 <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
450 <xsl:apply-templates/>
451 </xsl:when>
452 <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
453 <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
454 <xsl:apply-templates/>
455 </xsl:when>
456 <xsl:otherwise>
457 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
458 <xsl:apply-templates/>
459 </xsl:otherwise>
460 </xsl:choose>
461 </td>
462 </xsl:template>
463
464 <!-- dictionary -->
465 <xsl:template match="*:entry">
466 <!-- emp
467
468 + handled in text tag -->
469 </xsl:template>
470
471 <xsl:template match="*:form">
472 <span>
473 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
474 <xsl:attribute name="class"><xsl:value-of select="'form'"/></xsl:attribute>
475 <xsl:apply-templates/>
476 </span>
477 </xsl:template>
478
479 <xsl:template match="*:orth">
480 <span>
481 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
482 <xsl:attribute name="class"><xsl:value-of select="'orth'"/></xsl:attribute>
483 <xsl:apply-templates/>
484 </span>
485 </xsl:template>
486
487 <xsl:template match="*:sense">
488 <span>
489 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
490 <xsl:attribute name="class"><xsl:value-of select="'sense'"/></xsl:attribute>
491 <span class="entryDiv"><xsl:apply-templates select="*:def"/></span>
492 <span class="entryDiv"><xsl:apply-templates select="*:etym"/></span>
493 </span>
494 </xsl:template>
495
496 <xsl:template match="*:def">
497 <span>
498 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
499 <xsl:attribute name="class"><xsl:value-of select="'def'"/></xsl:attribute>
500 <span class="bf"><xsl:value-of select="'Definition: '"/></span>
501 <xsl:apply-templates/>
502 </span>
503 </xsl:template>
504
505 <xsl:template match="*:mentioned">
506 <span>
507 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
508 <xsl:attribute name="class"><xsl:value-of select="'mentioned'"/></xsl:attribute>
509 <xsl:apply-templates/>
510 </span>
511 </xsl:template>
512
513 <xsl:template match="*:etym">
514 <span>
515 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
516 <xsl:attribute name="class"><xsl:value-of select="'etym'"/></xsl:attribute>
517 <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
518 <span class="entryDiv">
519 <xsl:for-each select="*:cit">
520 <li><xsl:apply-templates select="*:quote"/><xsl:value-of select="' ('"/><xsl:apply-templates select="*:def"/><xsl:value-of select="')'"/></li>
521 </xsl:for-each>
522 </span>
523 </span>
524 </xsl:template>
525
526 <xsl:template match="*:cit">
527 <span>
528 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
529 <xsl:attribute name="class"><xsl:value-of select="'cit'"/></xsl:attribute>
530 <xsl:apply-templates/>
531 </span>
532 </xsl:template>
533
534 <!-- MathML -->
535 <xsl:template match="math:*">
536 <xsl:element name="{name()}" namespace="">
537 <xsl:copy-of select="@*"/>
538 <xsl:apply-templates/>
539 </xsl:element>
540 </xsl:template>
541
542 <!-- SVG -->
543 <xsl:template match="svg:*">
544 <xsl:element name="{name()}" namespace="">
545 <xsl:copy-of select="@*"/>
546 <xsl:apply-templates/>
547 </xsl:element>
548 </xsl:template>
549
550 <xsl:template match="*:lb">
551 <br>
552 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
553 <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
554 </br>
555 </xsl:template>
556
557 <xsl:template match="*:cb">
558 <br>
559 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
560 <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
561 </br>
562 </xsl:template>
563
564 <xsl:template match="*:note">
565 <xsl:variable name="position">
566 <xsl:choose>
567 <xsl:when test="empty(@place) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
568 <xsl:otherwise><xsl:value-of select="string(@place)"/></xsl:otherwise>
569 </xsl:choose>
570 </xsl:variable>
571 <xsl:variable name="type" select="'printed'"/>
572 <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
573 <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
574 <span>
575 <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
576 <span class="noteSign">
577 <xsl:choose>
578 <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
579 <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
580 </xsl:choose>
581 </span>
582 <xsl:if test="$position != 'foot'">
583 <span>
584 <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
585 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
586 <xsl:apply-templates/>
587 </span>
588 </xsl:if>
589 </span>
590 </xsl:template>
591
592 <xsl:template match="*:foreign">
593 <xsl:variable name="xmllang" select="@xml:lang"/>
594 <xsl:variable name="language">
595 <xsl:choose>
596 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
597 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
598 </xsl:choose>
599 </xsl:variable>
600 <span>
601 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
602 <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
603 <xsl:apply-templates/>
604 </span>
605 </xsl:template>
606
607 <xsl:template match="*:gap">
608 <span>
609 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
610 <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
611 <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
612 <xsl:apply-templates/>
613 </span>
614 </xsl:template>
615
616 <xsl:template match="*:s">
617 <span>
618 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
619 <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
620 <xsl:apply-templates/>
621 </span>
622 </xsl:template>
623
624 <!-- words -->
625 <xsl:template match="*:w">
626 <xsl:variable name="wordLanguage" select="@lang"/>
627 <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
628 <xsl:variable name="dictionary" select="string(@dictionary)"/>
629 <xsl:variable name="displayWordOrig">
630 <xsl:choose>
631 <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
632 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
633 </xsl:choose>
634 </xsl:variable>
635 <xsl:variable name="displayWordReg">
636 <xsl:choose>
637 <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
638 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
639 </xsl:choose>
640 </xsl:variable>
641 <xsl:variable name="displayWordNorm">
642 <xsl:choose>
643 <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
644 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
645 </xsl:choose>
646 </xsl:variable>
647 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
648 <xsl:variable name="dictionaryPart">
649 <xsl:choose>
650 <xsl:when test="$dictionary = 'true'">
651 <a class="dictionary">
652 <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
653 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
654 <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
655 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
656 </a>
657 </xsl:when>
658 <xsl:otherwise>
659 <span class="dictionary">
660 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
661 <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
662 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
663 </span>
664 </xsl:otherwise>
665 </xsl:choose>
666 </xsl:variable>
667 <xsl:variable name="displayWord">
668 <xsl:choose>
669 <xsl:when test="$displayWordOptions = ''">
670 <span class="w">
671 <xsl:sequence select="$dictionaryPart"/>
672 <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
673 <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
674 <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
675 </span>
676 </xsl:when>
677 <xsl:otherwise>
678 <span class="w">
679 <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
680 <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
681 <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
682 <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
683 </span>
684 </xsl:otherwise>
685 </xsl:choose>
686 </xsl:variable>
687 <xsl:sequence select="$displayWord"/>
688 </xsl:template>
689
690 </xsl:stylesheet>