comparison software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.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:echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"
11 xmlns:de="http://www.mpiwg-berlin.mpg.de/ns/de/1.0/"
12 xmlns:math="http://www.w3.org/1998/Math/MathML"
13 xmlns:mml="http://www.w3.org/1998/Math/MathML"
14 xmlns:svg="http://www.w3.org/2000/svg"
15 xmlns:xhtml="http://www.w3.org/1999/xhtml"
16 exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo de math mml svg xhtml"
17 >
18
19 <xsl:output method="xhtml" encoding="utf-8"/>
20
21 <xsl:param name="displayWordOptions"></xsl:param>
22 <xsl:param name="echoFiguresDir"></xsl:param>
23 <xsl:param name="echoPageImgDir"></xsl:param>
24
25 <xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
26
27 <xsl:template match="*:echo">
28 <div>
29 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
30 <xsl:attribute name="class"><xsl:value-of select="'echo'"/></xsl:attribute>
31 <xsl:apply-templates/>
32 </div>
33 </xsl:template>
34
35 <xsl:template match="*:text">
36 <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
37 <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
38 <xsl:variable name="bottomNotes" select="//*:note[contains(@position, 'foot') or empty(@position)]"/>
39 <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
40 <div>
41 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
42 <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
43 <xsl:apply-templates/>
44 <xsl:if test="$contentStr = '' and empty($figures)"> <!-- test if div only contains empty nodes but no figures -->
45 <div>
46 <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
47 <xsl:value-of select="'[Empty page]'"/>
48 </div>
49 </xsl:if>
50 <!-- Foot notes -->
51 <xsl:if test="$countBottomNotes > 0">
52 <div class="notes foot">
53 <xsl:for-each select="$bottomNotes">
54 <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
55 <span>
56 <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
57 <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
58 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
59 <span>
60 <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
61 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
62 <xsl:apply-templates/>
63 </span>
64 </span>
65 </xsl:for-each>
66 </div>
67 </xsl:if>
68 </div>
69 </xsl:template>
70
71 <xsl:template match="*:head">
72 <xsl:variable name="style" select="@style"/>
73 <div>
74 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
75 <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
76 <xsl:choose>
77 <xsl:when test="not(empty($style))">
78 <span>
79 <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
80 <xsl:apply-templates/>
81 </span>
82 </xsl:when>
83 <xsl:otherwise>
84 <xsl:apply-templates/>
85 </xsl:otherwise>
86 </xsl:choose>
87 </div>
88 </xsl:template>
89
90 <xsl:template match="*:figure">
91 <xsl:variable name="class">
92 <xsl:choose>
93 <xsl:when test="empty(@position)"><xsl:value-of select="name()"/></xsl:when>
94 <xsl:otherwise><xsl:value-of select="concat(name(), ' ', string(@position))"/></xsl:otherwise>
95 </xsl:choose>
96 </xsl:variable>
97 <xsl:variable name="image" select="*:image"/>
98 <xsl:variable name="caption" select="*:caption"/>
99 <xsl:variable name="description" select="*:description"/>
100 <xsl:variable name="variables" select="*:variables"/>
101 <span>
102 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
103 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
104 <xsl:if test="not(empty($image))">
105 <xsl:variable name="file" select="$image/@file"/>
106 <xsl:variable name="pn" select="$image/@pn"/>
107 <xsl:variable name="wx" select="$image/@wx"/>
108 <xsl:variable name="wy" select="$image/@wy"/>
109 <xsl:variable name="ww" select="$image/@ww"/>
110 <xsl:variable name="wh" select="$image/@wh"/>
111 <xsl:variable name="digilibServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html'"/>
112 <xsl:variable name="scalerServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler'"/>
113 <xsl:variable name="fileName">
114 <xsl:choose>
115 <xsl:when test="empty($wx) and empty($file)"><xsl:value-of select="$echoFiguresDir"/></xsl:when>
116 <xsl:when test="empty($wx) and not(empty($file))"><xsl:value-of select="concat($echoFiguresDir, '/', $file)"/></xsl:when>
117 <xsl:when test="not(empty($wx)) and empty($file)"><xsl:value-of select="$echoPageImgDir"/></xsl:when>
118 <xsl:when test="not(empty($wx)) and not(empty($file))"><xsl:value-of select="concat($echoPageImgDir, '/', $file)"/></xsl:when>
119 <xsl:otherwise><xsl:value-of select="$echoFiguresDir"/></xsl:otherwise>
120 </xsl:choose>
121 </xsl:variable>
122 <xsl:variable name="digilibUrl">
123 <xsl:choose>
124 <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:when>
125 <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn)"/></xsl:when>
126 <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
127 <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
128 <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:otherwise>
129 </xsl:choose>
130 </xsl:variable>
131 <xsl:variable name="scalerUrl">
132 <xsl:choose>
133 <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:when>
134 <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;dh=200&amp;dw=200')"/></xsl:when>
135 <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
136 <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
137 <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
138 </xsl:choose>
139 </xsl:variable>
140 <a href="{$digilibUrl}">
141 <img>
142 <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
143 </img>
144 </a>
145 </xsl:if>
146 <xsl:if test="not(empty(@number))">
147 <xsl:variable name="type"><xsl:value-of select="'Figure'"/></xsl:variable>
148 <span>
149 <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
150 <span>
151 <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
152 <xsl:value-of select="string(@number)"/>
153 </span>
154 <span>
155 <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
156 <xsl:value-of select="concat('[', $type, ' ', string(@number), ']')"/>
157 </span>
158 </span>
159 </xsl:if>
160 <xsl:if test="not(empty($caption))">
161 <xsl:for-each select="$caption">
162 <span class="caption"><xsl:apply-templates/></span>
163 </xsl:for-each>
164 </xsl:if>
165 <xsl:if test="not(empty($description))">
166 <xsl:for-each select="$description">
167 <span class="description"><xsl:apply-templates/></span>
168 </xsl:for-each>
169 </xsl:if>
170 <xsl:if test="not(empty($variables))">
171 <xsl:for-each select="$variables">
172 <span class="variables"><xsl:apply-templates/></span>
173 </xsl:for-each>
174 </xsl:if>
175 </span>
176 </xsl:template>
177
178 <!-- MathML -->
179 <xsl:template match="math:*">
180 <xsl:element name="{name()}" namespace="">
181 <xsl:copy-of select="@*"/>
182 <xsl:apply-templates/>
183 </xsl:element>
184 </xsl:template>
185
186 <xsl:template match="mml:*">
187 <xsl:element name="{name()}" namespace="">
188 <xsl:copy-of select="@*"/>
189 <xsl:apply-templates/>
190 </xsl:element>
191 </xsl:template>
192
193 <!-- XHTML: remove the xhtml namespace -->
194 <xsl:template match="xhtml:*">
195 <xsl:variable name="hasLabel" select="not(empty(@xhtml:label))"/>
196 <xsl:variable name="isTable" select="local-name() = 'table'"/>
197 <xsl:choose>
198 <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
199 <xsl:element name="{name()}" namespace="">
200 <xsl:copy-of select="@*"/>
201 <xsl:apply-templates/>
202 </xsl:element>
203 </xsl:when>
204 <xsl:otherwise></xsl:otherwise>
205 </xsl:choose>
206 </xsl:template>
207
208 <!-- SVG -->
209 <xsl:template match="svg:*">
210 <xsl:element name="{name()}" namespace="">
211 <xsl:copy-of select="@*"/>
212 <xsl:apply-templates/>
213 </xsl:element>
214 </xsl:template>
215
216 <xsl:template match="*:place|*:person">
217 <xsl:element name="span">
218 <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
219 <xsl:copy-of select="@*"/>
220 <xsl:apply-templates/>
221 </xsl:element>
222 </xsl:template>
223
224 <xsl:template match="*:div">
225 <xsl:if test="node() or normalize-space()"> <!-- test: contains nodes or is not empty -->
226 <div>
227 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
228 <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
229 <xsl:apply-templates/>
230 </div>
231 </xsl:if>
232 </xsl:template>
233
234 <xsl:template match="*:p">
235 <xsl:variable name="style" select="@style"/>
236 <xsl:variable name="class" select="'p'"/>
237 <div>
238 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
239 <xsl:choose>
240 <xsl:when test="not(empty($style))">
241 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
242 <span>
243 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
244 <xsl:apply-templates/>
245 </span>
246 </xsl:when>
247 <xsl:otherwise>
248 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
249 <xsl:apply-templates/>
250 </xsl:otherwise>
251 </xsl:choose>
252 </div>
253 </xsl:template>
254
255 <xsl:template match="*:pb">
256 <xsl:variable name="number">
257 <xsl:choose>
258 <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
259 <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
260 </xsl:choose>
261 </xsl:variable>
262 <xsl:variable name="file">
263 <xsl:choose>
264 <xsl:when test="not(empty(@file))"><xsl:value-of select="@file"/></xsl:when>
265 <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
266 </xsl:choose>
267 </xsl:variable>
268 <span>
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="'pb'"/></xsl:attribute>
271 <span>
272 <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
273 <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
274 <span>
275 <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
276 <xsl:value-of select="$number"/>
277 </span>
278 <xsl:if test="not(empty(@o))">
279 <span>
280 <xsl:attribute name="class"><xsl:value-of select="'o'"/></xsl:attribute>
281 <xsl:value-of select="@o"/>
282 </span>
283 </xsl:if>
284 <xsl:if test="not(empty(@rhead))">
285 <span>
286 <xsl:attribute name="class"><xsl:value-of select="'rhead'"/></xsl:attribute>
287 <xsl:value-of select="@rhead"/>
288 </span>
289 </xsl:if>
290 </span>
291 </span>
292 </xsl:template>
293
294 <xsl:template match="*:lb">
295 <br>
296 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
297 <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
298 </br>
299 </xsl:template>
300
301 <xsl:template match="*:cb">
302 <br>
303 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
304 <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
305 </br>
306 </xsl:template>
307
308 <xsl:template match="*:expan">
309 <span>
310 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
311 <xsl:attribute name="class"><xsl:value-of select="'expan'"/></xsl:attribute>
312 <xsl:apply-templates/>
313 </span>
314 </xsl:template>
315
316 <xsl:template match="*:note|*:handwritten">
317 <xsl:variable name="position">
318 <xsl:choose>
319 <xsl:when test="empty(@position) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
320 <xsl:when test="empty(@position) and name() = 'handwritten'"><xsl:value-of select="'margin'"/></xsl:when>
321 <xsl:otherwise><xsl:value-of select="string(@position)"/></xsl:otherwise>
322 </xsl:choose>
323 </xsl:variable>
324 <xsl:variable name="type">
325 <xsl:choose>
326 <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
327 <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
328 <xsl:otherwise></xsl:otherwise>
329 </xsl:choose>
330 </xsl:variable>
331 <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
332 <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
333 <span>
334 <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
335 <span class="noteSign">
336 <xsl:choose>
337 <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
338 <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
339 </xsl:choose>
340 </span>
341 <xsl:if test="$position != 'foot'">
342 <span>
343 <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
344 <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
345 <xsl:apply-templates/>
346 <xsl:if test="$type = 'handwritten'">
347 <span>
348 <xsl:attribute name="class"><xsl:value-of select="'noteNumText'"/></xsl:attribute>
349 <xsl:value-of select="concat('[Handwritten note ', string(@number), ']')"/>
350 </span>
351 </xsl:if>
352 </span>
353 </xsl:if>
354 </span>
355 </xsl:template>
356
357 <xsl:template match="*:emph">
358 <span>
359 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
360 <xsl:attribute name="class"><xsl:value-of select="'emph'"/></xsl:attribute>
361 <xsl:choose>
362 <xsl:when test="not(empty(@style))">
363 <span>
364 <xsl:attribute name="class"><xsl:value-of select="string(@style)"/></xsl:attribute>
365 <xsl:apply-templates/>
366 </span>
367 </xsl:when>
368 <xsl:otherwise>
369 <xsl:apply-templates/>
370 </xsl:otherwise>
371 </xsl:choose>
372 </span>
373 </xsl:template>
374
375 <xsl:template match="*:foreign">
376 <xsl:variable name="lang" select="@lang"/>
377 <xsl:variable name="xmllang" select="@xml:lang"/>
378 <xsl:variable name="language">
379 <xsl:choose>
380 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
381 <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
382 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
383 </xsl:choose>
384 </xsl:variable>
385 <xsl:variable name="class">
386 <xsl:choose>
387 <xsl:when test="$language = ''"><xsl:value-of select="'foreign'"/></xsl:when>
388 <xsl:otherwise><xsl:value-of select="concat('foreign ', $language)"/></xsl:otherwise>
389 </xsl:choose>
390 </xsl:variable>
391 <span>
392 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
393 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
394 <xsl:apply-templates/>
395 </span>
396 </xsl:template>
397
398 <xsl:template match="*:q">
399 <span>
400 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
401 <xsl:attribute name="class"><xsl:value-of select="'q'"/></xsl:attribute>
402 <xsl:apply-templates/>
403 </span>
404 </xsl:template>
405
406 <xsl:template match="*:quote">
407 <span class="quote">
408 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
409 <xsl:apply-templates/>
410 </span>
411 </xsl:template>
412
413 <xsl:template match="*:blockquote">
414 <span>
415 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
416 <xsl:attribute name="class"><xsl:value-of select="'blockquote'"/></xsl:attribute>
417 <xsl:apply-templates/>
418 </span>
419 </xsl:template>
420
421 <xsl:template match="*:set-off">
422 <span>
423 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
424 <xsl:attribute name="class"><xsl:value-of select="'set-off'"/></xsl:attribute>
425 <xsl:apply-templates/>
426 </span>
427 </xsl:template>
428
429 <xsl:template match="*:reg">
430 <span class="reg">
431 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
432 <xsl:attribute name="class"><xsl:value-of select="'reg'"/></xsl:attribute>
433 <xsl:apply-templates/>
434 </span>
435 </xsl:template>
436
437 <xsl:template match="*:var">
438 <xsl:variable name="class">
439 <xsl:choose>
440 <xsl:when test="empty(@type)"><xsl:value-of select="'var'"/></xsl:when>
441 <xsl:otherwise><xsl:value-of select="concat('var ', string(@type))"/></xsl:otherwise>
442 </xsl:choose>
443 </xsl:variable>
444 <span>
445 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
446 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
447 <xsl:apply-templates/>
448 </span>
449 </xsl:template>
450
451 <xsl:template match="*:num">
452 <span>
453 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
454 <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
455 <xsl:apply-templates/>
456 </span>
457 </xsl:template>
458
459 <xsl:template match="*:gap">
460 <span>
461 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
462 <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
463 <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
464 <xsl:apply-templates/>
465 </span>
466 </xsl:template>
467
468 <xsl:template match="*:s">
469 <span>
470 <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
471 <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
472 <xsl:apply-templates/>
473 </span>
474 </xsl:template>
475
476 <!-- words -->
477 <xsl:template match="*:w">
478 <xsl:variable name="wordLanguage" select="@lang"/>
479 <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
480 <xsl:variable name="dictionary" select="string(@dictionary)"/>
481 <xsl:variable name="displayWordOrig">
482 <xsl:choose>
483 <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
484 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
485 </xsl:choose>
486 </xsl:variable>
487 <xsl:variable name="displayWordReg">
488 <xsl:choose>
489 <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
490 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
491 </xsl:choose>
492 </xsl:variable>
493 <xsl:variable name="displayWordNorm">
494 <xsl:choose>
495 <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
496 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
497 </xsl:choose>
498 </xsl:variable>
499 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
500 <xsl:variable name="dictionaryPart">
501 <xsl:choose>
502 <xsl:when test="$dictionary = 'true'">
503 <a class="dictionary">
504 <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>
505 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
506 <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
507 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
508 </a>
509 </xsl:when>
510 <xsl:otherwise>
511 <span class="dictionary">
512 <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
513 <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
514 <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
515 </span>
516 </xsl:otherwise>
517 </xsl:choose>
518 </xsl:variable>
519 <xsl:variable name="displayWord">
520 <xsl:choose>
521 <xsl:when test="$displayWordOptions = ''">
522 <span class="w">
523 <xsl:sequence select="$dictionaryPart"/>
524 <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
525 <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
526 <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
527 </span>
528 </xsl:when>
529 <xsl:otherwise>
530 <span class="w">
531 <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
532 <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
533 <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
534 <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
535 </span>
536 </xsl:otherwise>
537 </xsl:choose>
538 </xsl:variable>
539 <xsl:sequence select="$displayWord"/>
540 </xsl:template>
541
542 <xsl:template match="*:hi">
543 <xsl:choose>
544 <xsl:when test="@type = 'elem'">
545 <div>
546 <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
547 <xsl:apply-templates/>
548 </div>
549 </xsl:when>
550 <xsl:otherwise>
551 <span>
552 <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
553 <xsl:apply-templates/>
554 </span>
555 </xsl:otherwise>
556 </xsl:choose>
557 </xsl:template>
558
559 </xsl:stylesheet>