comparison software/mpdl-services/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl @ 23:e845310098ba

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