comparison software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/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 distinguished from word links within it -->
381 <xsl:template match="*:ref">
382 <xsl:variable name="refPos"><xsl:value-of select="count(./preceding::*:ref) + 1"/></xsl:variable>
383 <span>
384 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
385 <xsl:attribute name="class"><xsl:value-of select="'ref'"/></xsl:attribute>
386 <xsl:if test="not(empty(@target))">
387 <a class="ref">
388 <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
389 <span class="super"><xsl:value-of select="concat('[', $refPos)"/></span>
390 </a>
391 <xsl:value-of select="' '"/>
392 <xsl:apply-templates/>
393 <xsl:value-of select="' '"/>
394 <a class="ref">
395 <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
396 <span class="super"><xsl:value-of select="concat($refPos, ']')"/></span>
397 </a>
398 </xsl:if>
399 <xsl:if test="empty(@target)">
400 <xsl:apply-templates/>
401 </xsl:if>
402 </span>
403 </xsl:template>
404
405 <!-- table -->
406 <xsl:template match="*:table">
407 <table>
408 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
409 <xsl:if test="not(empty(head))">
410 <caption align="top"><xsl:apply-templates select="*:head"/></caption>
411 </xsl:if>
412 <xsl:apply-templates select="*:row"/>
413 </table>
414 </xsl:template>
415
416 <xsl:template match="*:row">
417 <tr>
418 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
419 <xsl:choose>
420 <xsl:when test="@role = 'label'">
421 <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
422 <xsl:apply-templates/>
423 </xsl:when>
424 <xsl:when test="@role = 'data' or empty(@role)">
425 <xsl:apply-templates/>
426 </xsl:when>
427 <xsl:otherwise>
428 <xsl:apply-templates/>
429 </xsl:otherwise>
430 </xsl:choose>
431 </tr>
432 </xsl:template>
433
434 <xsl:template match="*:cell">
435 <td>
436 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
437 <xsl:choose>
438 <xsl:when test="@role = 'label' and empty(@cols)">
439 <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
440 <xsl:apply-templates/>
441 </xsl:when>
442 <xsl:when test="@role = 'label' and not(empty(@cols))">
443 <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
444 <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
445 <xsl:apply-templates/>
446 </xsl:when>
447 <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
448 <xsl:apply-templates/>
449 </xsl:when>
450 <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
451 <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
452 <xsl:apply-templates/>
453 </xsl:when>
454 <xsl:otherwise>
455 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
456 <xsl:apply-templates/>
457 </xsl:otherwise>
458 </xsl:choose>
459 </td>
460 </xsl:template>
461
462 <!-- dictionary -->
463 <xsl:template match="*:entry">
464 <!-- empty: handled in text tag -->
465 </xsl:template>
466
467 <xsl:template match="*:form">
468 <span>
469 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
470 <xsl:attribute name="class"><xsl:value-of select="'form'"/></xsl:attribute>
471 <xsl:apply-templates/>
472 </span>
473 </xsl:template>
474
475 <xsl:template match="*:orth">
476 <span>
477 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
478 <xsl:attribute name="class"><xsl:value-of select="'orth'"/></xsl:attribute>
479 <xsl:apply-templates/>
480 </span>
481 </xsl:template>
482
483 <xsl:template match="*:sense">
484 <span>
485 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
486 <xsl:attribute name="class"><xsl:value-of select="'sense'"/></xsl:attribute>
487 <span class="entryDiv"><xsl:apply-templates select="*:def"/></span>
488 <span class="entryDiv"><xsl:apply-templates select="*:etym"/></span>
489 </span>
490 </xsl:template>
491
492 <xsl:template match="*:def">
493 <span>
494 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
495 <xsl:attribute name="class"><xsl:value-of select="'def'"/></xsl:attribute>
496 <span class="bf"><xsl:value-of select="'Definition: '"/></span>
497 <xsl:apply-templates/>
498 </span>
499 </xsl:template>
500
501 <xsl:template match="*:mentioned">
502 <span>
503 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
504 <xsl:attribute name="class"><xsl:value-of select="'mentioned'"/></xsl:attribute>
505 <xsl:apply-templates/>
506 </span>
507 </xsl:template>
508
509 <xsl:template match="*:etym">
510 <span>
511 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
512 <xsl:attribute name="class"><xsl:value-of select="'etym'"/></xsl:attribute>
513 <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
514 <span class="entryDiv">
515 <xsl:for-each select="*:cit">
516 <li><xsl:apply-templates select="*:quote"/><xsl:value-of select="' ('"/><xsl:apply-templates select="*:def"/><xsl:value-of select="')'"/></li>
517 </xsl:for-each>
518 </span>
519 </span>
520 </xsl:template>
521
522 <xsl:template match="*:cit">
523 <span>
524 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
525 <xsl:attribute name="class"><xsl:value-of select="'cit'"/></xsl:attribute>
526 <xsl:apply-templates/>
527 </span>
528 </xsl:template>
529
530 <!-- MathML -->
531 <xsl:template match="math:*">
532 <xsl:element name="{name()}" namespace="">
533 <xsl:copy-of select="@*"/>
534 <xsl:apply-templates/>
535 </xsl:element>
536 </xsl:template>
537
538 <!-- SVG -->
539 <xsl:template match="svg:*">
540 <xsl:element name="{name()}" namespace="">
541 <xsl:copy-of select="@*"/>
542 <xsl:apply-templates/>
543 </xsl:element>
544 </xsl:template>
545
546 <xsl:template match="*:lb">
547 <br>
548 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
549 <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
550 </br>
551 </xsl:template>
552
553 <xsl:template match="*:cb">
554 <br>
555 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
556 <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
557 </br>
558 </xsl:template>
559
560 <xsl:template match="*:note">
561 <xsl:variable name="position">
562 <xsl:choose>
563 <xsl:when test="empty(@place) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
564 <xsl:otherwise><xsl:value-of select="string(@place)"/></xsl:otherwise>
565 </xsl:choose>
566 </xsl:variable>
567 <xsl:variable name="type" select="'printed'"/>
568 <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
569 <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
570 <span>
571 <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
572 <span class="noteSign">
573 <xsl:choose>
574 <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
575 <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
576 </xsl:choose>
577 </span>
578 <xsl:if test="$position != 'foot'">
579 <span>
580 <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
581 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
582 <xsl:apply-templates/>
583 </span>
584 </xsl:if>
585 </span>
586 </xsl:template>
587
588 <xsl:template match="*:foreign">
589 <xsl:variable name="xmllang" select="@xml:lang"/>
590 <xsl:variable name="language">
591 <xsl:choose>
592 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
593 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
594 </xsl:choose>
595 </xsl:variable>
596 <span>
597 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
598 <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
599 <xsl:apply-templates/>
600 </span>
601 </xsl:template>
602
603 <xsl:template match="*:gap">
604 <span>
605 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
606 <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
607 <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
608 <xsl:apply-templates/>
609 </span>
610 </xsl:template>
611
612 <xsl:template match="*:s">
613 <span>
614 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
615 <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
616 <xsl:apply-templates/>
617 </span>
618 </xsl:template>
619
620 <!-- words -->
621 <xsl:template match="*:w">
622 <xsl:variable name="wordLanguage" select="@lang"/>
623 <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
624 <xsl:variable name="dictionary" select="string(@dictionary)"/>
625 <xsl:variable name="displayWordOrig">
626 <xsl:choose>
627 <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
628 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
629 </xsl:choose>
630 </xsl:variable>
631 <xsl:variable name="displayWordReg">
632 <xsl:choose>
633 <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
634 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
635 </xsl:choose>
636 </xsl:variable>
637 <xsl:variable name="displayWordNorm">
638 <xsl:choose>
639 <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
640 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
641 </xsl:choose>
642 </xsl:variable>
643 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
644 <xsl:variable name="dictionaryPart">
645 <xsl:choose>
646 <xsl:when test="$dictionary = 'true'">
647 <a class="dictionary">
648 <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>
649 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
650 <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
651 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
652 </a>
653 </xsl:when>
654 <xsl:otherwise>
655 <span class="dictionary">
656 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
657 <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
658 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
659 </span>
660 </xsl:otherwise>
661 </xsl:choose>
662 </xsl:variable>
663 <xsl:variable name="displayWord">
664 <xsl:choose>
665 <xsl:when test="$displayWordOptions = ''">
666 <span class="w">
667 <xsl:sequence select="$dictionaryPart"/>
668 <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
669 <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
670 <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
671 </span>
672 </xsl:when>
673 <xsl:otherwise>
674 <span class="w">
675 <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
676 <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
677 <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
678 <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
679 </span>
680 </xsl:otherwise>
681 </xsl:choose>
682 </xsl:variable>
683 <xsl:sequence select="$displayWord"/>
684 </xsl:template>
685
686 </xsl:stylesheet>