comparison software/mpdl-services/mpiwg-mpdl-xml/build/classes/de/mpg/mpiwg/berlin/mpdl/xml/transform/pageArchimedes.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:math="http://www.w3.org/1998/Math/MathML"
12 xmlns:mml="http://www.w3.org/1998/Math/MathML"
13 xmlns:svg="http://www.w3.org/2000/svg"
14 xmlns:xhtml="http://www.w3.org/1999/xhtml">
15
16 <xsl:output method="xhtml" encoding="utf-8"/>
17
18 <xsl:variable name="collectionName" select="'echo'"/>
19 <xsl:variable name="polluxServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
20
21 <xsl:template match="/">
22 <xsl:apply-templates mode="text"/>
23 </xsl:template>
24
25 <xsl:template match="text" mode="text">
26 <xsl:apply-templates mode="text"/>
27 <!-- TEI Dictionary -->
28 <xsl:if test="not(empty(//entry))">
29 <xsl:for-each select="//entry">
30 <xsl:sort select="form/orth"/>
31 <xsl:variable name="position" select="position()"/>
32 <span class="entry">
33 <xsl:apply-templates mode="text" select="form"/>
34 <xsl:apply-templates mode="text" select="sense"/>
35 <xsl:if test="not(empty(figure))">
36 <span class="entryDiv">
37 <span class="bf"><xsl:value-of select="'Figures: '"/></span>
38 <span class="entryDiv">
39 <xsl:for-each select="figure">
40 <xsl:variable name="href" select="graphic/@url"/>
41 <xsl:variable name="head" select="head"/>
42 <xsl:variable name="figDesc" select="string(figDesc)"/>
43 <xsl:if test="$href != ''">
44 <div class="figure" style="margin-left:10px;">
45 <a href="{$href}"><img alt="Figure: {$figDesc}" src="{$href}" width="200" height="200"/></a>
46 <br/>
47 <xsl:value-of select="'[Figure]: '"/><xsl:value-of select="$head"/>
48 </div>
49 </xsl:if>
50 </xsl:for-each>
51 </span>
52 </span>
53 </xsl:if>
54 <xsl:if test="not(empty(xr))">
55 <span class="entryDiv">
56 <span class="bf"><xsl:value-of select="'References: '"/></span>
57 <span class="entryDiv">
58 <xsl:for-each select="xr/ref">
59 <li><xsl:apply-templates mode="text" select="."/></li>
60 </xsl:for-each>
61 </span>
62 </span>
63 </xsl:if>
64 </span>
65 </xsl:for-each>
66 </xsl:if>
67 <!-- Notes -->
68 <!--
69 <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
70 <xsl:variable name="countBottomPlaces">
71 <xsl:choose>
72 <xsl:when test="$collectionName = 'archimedes' or $collectionName = 'tei'">
73 <xsl:value-of select="count($notes/note[contains(@place, 'bottom')])"/>
74 </xsl:when>
75 <xsl:otherwise>
76 <xsl:value-of select="count($notes/note[contains(@position, 'bottom') or empty(string(@position))])"/>
77 </xsl:otherwise>
78 </xsl:choose>
79 </xsl:variable>
80 <xsl:if test="($collectionName = 'archimedes' or $collectionName = 'tei') and count($notes/*) > 0">
81 <div>
82 <xsl:choose>
83 <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
84 <hr class="notesBottom"/>
85 </xsl:when>
86 <xsl:otherwise></xsl:otherwise>
87 </xsl:choose>
88 <xsl:for-each select="$notes/note">
89 <xsl:variable name="notePos" select="position()"/>
90 <xsl:variable name="place" select="@place"/>
91 <xsl:variable name="label" select="$notePos"/>
92 <xsl:variable name="uid" select="@uid"/>
93 <xsl:variable name="modificationDate" select="@modificationDate"/>
94 <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
95 <xsl:choose>
96 <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
97 <p>
98 <a>
99 <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute>
100 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute>
101 <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
102 <xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/>
103 </a>
104 <xsl:value-of select="': '"/>
105 <xsl:choose>
106 <xsl:when test="$uid = '' or empty($uid)">
107 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
108 </xsl:when>
109 <xsl:otherwise>
110 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
111 <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
112 </xsl:otherwise>
113 </xsl:choose>
114 </p>
115 </xsl:when>
116 <xsl:otherwise></xsl:otherwise>
117 </xsl:choose>
118 </xsl:for-each>
119 </div>
120 </xsl:if>
121 <xsl:if test="$collectionName = 'echo' and count($notes/*) > 0">
122 <div>
123 <xsl:choose>
124 <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
125 <hr class="notesBottom"/>
126 </xsl:when>
127 <xsl:otherwise></xsl:otherwise>
128 </xsl:choose>
129 <xsl:for-each select="$notes/echo:note">
130 <xsl:variable name="label" select="string(@xlink:label)"/>
131 <xsl:variable name="place" select="@position"/>
132 <xsl:variable name="uid" select="@uid"/>
133 <xsl:variable name="modificationDate" select="@modificationDate"/>
134 <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
135 <xsl:choose>
136 <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
137 <p>
138 <a>
139 <xsl:attribute name="name"><xsl:value-of select="$label"/></xsl:attribute>
140 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $label, 'ref')"/></xsl:attribute>
141 <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
142 <xsl:value-of select="$label"/>
143 </a>
144 <xsl:value-of select="': '"/>
145 <xsl:choose>
146 <xsl:when test="$uid = '' or empty($uid)">
147 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
148 </xsl:when>
149 <xsl:otherwise>
150 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
151 <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
152 </xsl:otherwise>
153 </xsl:choose>
154 </p>
155 </xsl:when>
156 <xsl:otherwise></xsl:otherwise>
157 </xsl:choose>
158 </xsl:for-each>
159 </div>
160 </xsl:if>
161 -->
162 </xsl:template>
163
164 <xsl:template match="head" mode="text">
165 <xsl:variable name="class">
166 <xsl:value-of select="'head bf'"/>
167 </xsl:variable>
168 <p>
169 <span>
170 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
171 <xsl:apply-templates mode="text"/>
172 </span>
173 </p>
174 </xsl:template>
175
176 <!-- TEI: segmentation -->
177 <xsl:template match="seg" mode="text">
178 <xsl:choose>
179 <xsl:when test="@rend = 'highlight'">
180 <span class="seg highlight"><xsl:apply-templates mode="text"/></span>
181 </xsl:when>
182 <xsl:when test="@rend = 'highlightPoint'">
183 <span class="seg highlightPoint"><xsl:apply-templates mode="text"/></span>
184 </xsl:when>
185 <xsl:otherwise>
186 <span class="seg"><xsl:apply-templates mode="text"/></span>
187 </xsl:otherwise>
188 </xsl:choose>
189 </xsl:template>
190
191 <!-- TEI: choice -->
192 <xsl:template match="choice" mode="text">
193 <xsl:if test="not(empty(orig))">
194 <xsl:apply-templates select="orig" mode="text"/>
195 </xsl:if>
196 <xsl:if test="not(empty(abbr))">
197 <xsl:apply-templates select="abbr" mode="text"/>
198 </xsl:if>
199 <xsl:if test="not(empty(am))">
200 <xsl:apply-templates select="am" mode="text"/>
201 </xsl:if>
202 <xsl:if test="not(empty(sic))">
203 <xsl:apply-templates select="sic" mode="text"/>
204 </xsl:if>
205 </xsl:template>
206
207 <!-- TEI: hi (highlighted) -->
208 <xsl:template match="hi" mode="text">
209 <xsl:choose>
210 <xsl:when test="@rend = 'initial'">
211 <span class="dc-unmodified"><xsl:apply-templates mode="text"/></span>
212 </xsl:when>
213 <xsl:when test="@rend = 'bold'">
214 <span class="bf"><xsl:apply-templates mode="text"/></span>
215 </xsl:when>
216 <xsl:otherwise>
217 <span>
218 <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
219 <xsl:apply-templates mode="text"/>
220 </span>
221 </xsl:otherwise>
222 </xsl:choose>
223 </xsl:template>
224
225 <!-- TEI: name (of type: place, person, ...) -->
226 <xsl:template match="name" mode="text">
227 <xsl:choose>
228 <xsl:when test="@type = 'place'">
229 <span class="place" title="Place"><xsl:apply-templates mode="text"/></span>
230 </xsl:when>
231 <xsl:when test="@type = 'person'">
232 <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
233 </xsl:when>
234 <xsl:when test="@type = 'org'">
235 <span class="organization" title="Organization"><xsl:apply-templates mode="text"/></span>
236 </xsl:when>
237 <xsl:otherwise>
238 <span>
239 <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
240 <xsl:apply-templates mode="text"/>
241 </span>
242 </xsl:otherwise>
243 </xsl:choose>
244 </xsl:template>
245
246 <!-- TEI: place, person, ...) -->
247 <xsl:template match="placeName" mode="text">
248 <span class="place" title="Place: {@type}"><xsl:apply-templates mode="text"/></span>
249 </xsl:template>
250 <xsl:template match="persName" mode="text">
251 <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
252 </xsl:template>
253
254 <!-- TEI: term -->
255 <xsl:template match="term" mode="text">
256 <span class="term" title="Terminology entry"><xsl:apply-templates mode="text"/></span>
257 </xsl:template>
258
259 <!-- TEI: line -->
260 <xsl:template match="lg" mode="text">
261 <div class="lg"><xsl:apply-templates mode="text"/></div>
262 </xsl:template>
263
264 <xsl:template match="l" mode="text">
265 <span class="l"><xsl:apply-templates mode="text"/></span><br/>
266 </xsl:template>
267
268 <!-- TEI: reference -->
269 <xsl:template match="ref" mode="text">
270 <span class="ref">
271 <xsl:if test="not(empty(@target))">
272 <a>
273 <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
274 <xsl:apply-templates mode="text"/>
275 </a>
276 </xsl:if>
277 <xsl:if test="empty(@target)">
278 <xsl:apply-templates mode="text"/>
279 </xsl:if>
280 </span>
281 </xsl:template>
282
283 <!-- TEI: table -->
284 <xsl:template match="table" mode="text">
285 <table>
286 <xsl:if test="not(empty(head))">
287 <caption align="top"><xsl:apply-templates mode="text" select="head"/></caption>
288 </xsl:if>
289 <xsl:apply-templates mode="text" select="row"/>
290 </table>
291 </xsl:template>
292
293 <xsl:template match="row" mode="text">
294 <xsl:choose>
295 <xsl:when test="@role = 'label'">
296 <tr style="font-weight:bold;"><xsl:apply-templates mode="text"/></tr>
297 </xsl:when>
298 <xsl:when test="@role = 'data' or empty(@role)">
299 <tr><xsl:apply-templates mode="text"/></tr>
300 </xsl:when>
301 <xsl:otherwise>
302 <tr><xsl:apply-templates mode="text"/></tr>
303 </xsl:otherwise>
304 </xsl:choose>
305 </xsl:template>
306
307 <xsl:template match="cell" mode="text">
308 <xsl:choose>
309 <xsl:when test="@role = 'label' and empty(@cols)">
310 <td style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
311 </xsl:when>
312 <xsl:when test="@role = 'label' and not(empty(@cols))">
313 <td colspan="{@cols}" style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
314 </xsl:when>
315 <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
316 <td><xsl:apply-templates mode="text"/></td>
317 </xsl:when>
318 <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
319 <td colspan="{@cols}"><xsl:apply-templates mode="text"/></td>
320 </xsl:when>
321 <xsl:otherwise>
322 <td><xsl:apply-templates mode="text"/></td>
323 </xsl:otherwise>
324 </xsl:choose>
325 </xsl:template>
326
327 <!-- TEI: dictionary -->
328 <xsl:template match="entry" mode="text">
329 <!-- empty: handled in text tag -->
330 </xsl:template>
331
332 <xsl:template match="form" mode="text">
333 <span class="form">
334 <xsl:apply-templates mode="text"/>
335 </span>
336 </xsl:template>
337
338 <xsl:template match="orth" mode="text">
339 <span class="orth">
340 <xsl:apply-templates mode="text"/>
341 </span>
342 </xsl:template>
343
344 <xsl:template match="sense" mode="text">
345 <span class="entryDiv"><xsl:apply-templates mode="text" select="def"/></span>
346 <span class="entryDiv"><xsl:apply-templates mode="text" select="etym"/></span>
347 </xsl:template>
348
349 <xsl:template match="def" mode="text">
350 <span class="def">
351 <span class="bf"><xsl:value-of select="'Definition: '"/></span>
352 <xsl:apply-templates mode="text"/>
353 </span>
354 </xsl:template>
355
356 <xsl:template match="mentioned" mode="text">
357 <span class="mentioned">
358 <xsl:apply-templates mode="text"/>
359 </span>
360 </xsl:template>
361
362 <xsl:template match="etym" mode="text">
363 <span class="etym">
364 <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
365 <span class="entryDiv">
366 <xsl:for-each select="cit">
367 <li><xsl:value-of select="quote"/><xsl:value-of select="' ('"/><xsl:value-of select="def"/><xsl:value-of select="')'"/></li>
368 </xsl:for-each>
369 </span>
370 </span>
371 </xsl:template>
372
373 <xsl:template match="cit" mode="text">
374 <span class="cit">
375 <xsl:apply-templates mode="text"/>
376 </span>
377 </xsl:template>
378
379 <!-- TEI: MathML -->
380 <xsl:template match="math:*" mode="text">
381 <xsl:element name="{name()}" namespace="">
382 <xsl:copy-of select="@*"/>
383 <xsl:apply-templates mode="text"/>
384 </xsl:element>
385 </xsl:template>
386
387 <!-- TEI: SVG -->
388 <xsl:template match="svg:*" mode="text">
389 <xsl:element name="{name()}" namespace="">
390 <xsl:copy-of select="@*"/>
391 <xsl:apply-templates mode="text"/>
392 </xsl:element>
393 </xsl:template>
394
395 <xsl:template match="div" mode="text">
396 <xsl:variable name="type" select="@type"/>
397 <xsl:variable name="level" select="@level"/>
398 <xsl:variable name="style" select="@style"/>
399 <xsl:variable name="border" select="@border"/>
400 <xsl:variable name="width" select="@width"/>
401 <xsl:variable name="note" select="note"/>
402 <xsl:variable name="figure" select="figure"/>
403 <xsl:variable name="floatClassValue">
404 <xsl:choose>
405 <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when>
406 <xsl:when test="not(empty($figure))"><xsl:value-of select="''"/></xsl:when>
407 <xsl:when test="$type = 'float'"><xsl:value-of select="'float left'"/></xsl:when>
408 <xsl:otherwise><xsl:value-of select="'float left'"/></xsl:otherwise>
409 </xsl:choose>
410 </xsl:variable>
411 <xsl:variable name="levelClassValue">
412 <xsl:choose>
413 <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when>
414 <xsl:when test="$level = '1'"><xsl:value-of select="'level one'"/></xsl:when>
415 <xsl:when test="$level = '2'"><xsl:value-of select="'level two'"/></xsl:when>
416 <xsl:when test="$level = '3'"><xsl:value-of select="'level three'"/></xsl:when>
417 <xsl:when test="$level = '4'"><xsl:value-of select="'level four'"/></xsl:when>
418 <xsl:when test="$level = '5'"><xsl:value-of select="'level five'"/></xsl:when>
419 <xsl:when test="$level = '6'"><xsl:value-of select="'level six'"/></xsl:when>
420 <xsl:when test="$level = '7'"><xsl:value-of select="'level seven'"/></xsl:when>
421 <xsl:when test="$level = '8'"><xsl:value-of select="'level eight'"/></xsl:when>
422 <xsl:when test="$level = '9'"><xsl:value-of select="'level nine'"/></xsl:when>
423 <xsl:when test="empty($level)"><xsl:value-of select="''"/></xsl:when>
424 <xsl:otherwise><xsl:value-of select="'level n'"/></xsl:otherwise>
425 </xsl:choose>
426 </xsl:variable>
427 <div>
428 <xsl:if test="not(empty($style))"><xsl:attribute name="style"><xsl:value-of select="$style"/></xsl:attribute></xsl:if>
429 <xsl:attribute name="class"><xsl:value-of select="concat($floatClassValue, ' ', $levelClassValue)"/></xsl:attribute>
430 <xsl:apply-templates mode="text"/>
431 </div>
432 </xsl:template>
433
434 <xsl:template match="p" mode="text">
435 <xsl:variable name="style" select="@style"/>
436 <xsl:variable name="class">
437 <xsl:value-of select="'p'"/>
438 </xsl:variable>
439 <xsl:choose>
440 <xsl:when test="not(empty($style))">
441 <div>
442 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
443 <span>
444 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
445 <xsl:apply-templates mode="text"/>
446 </span>
447 </div>
448 </xsl:when>
449 <xsl:otherwise>
450 <div>
451 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
452 <xsl:apply-templates mode="text"/>
453 </div>
454 </xsl:otherwise>
455 </xsl:choose>
456 </xsl:template>
457
458 <xsl:template match="lb|br" mode="text">
459 <br></br><xsl:apply-templates mode="text"/>
460 </xsl:template>
461
462 <xsl:template match="cb" mode="text">
463 <br/><xsl:apply-templates mode="text"/>
464 </xsl:template>
465
466 <xsl:template match="expan" mode="text">
467 <xsl:choose>
468 <xsl:when test="not(empty(@style))">
469 <span>
470 <xsl:attribute name="class"><xsl:value-of select="concat('expan ', @style)"/></xsl:attribute>
471 <xsl:apply-templates mode="text"/>
472 </span>
473 </xsl:when>
474 <xsl:otherwise>
475 <span class="expan"><xsl:apply-templates mode="text"/></span>
476 </xsl:otherwise>
477 </xsl:choose>
478 </xsl:template>
479
480 <xsl:template match="note" mode="text">
481 <!--
482 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
483 <xsl:variable name="place">
484 <xsl:choose>
485 <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="@place"/></xsl:when>
486 <xsl:otherwise><xsl:value-of select="@position"/></xsl:otherwise>
487 </xsl:choose>
488 </xsl:variable>
489 <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/>
490 <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/>
491 <xsl:choose>
492 <xsl:when test="$collectionName = 'archimedes'">
493 <a>
494 <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute>
495 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute>
496 <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
497 <xsl:value-of select="$href"/>
498 </a>
499 </xsl:when>
500 <xsl:when test="$collectionName = 'echo' and not($hasLabel) and not(empty($place))">
501 <span>
502 <xsl:attribute name="class"><xsl:value-of select="concat('note margin ', $place)"/></xsl:attribute>
503 <xsl:apply-templates mode="text"/>
504 </span>
505 </xsl:when>
506 <xsl:when test="$collectionName = 'echo' and not($hasLabel)">
507 <p>
508 <xsl:value-of select="'[Note]: '"/>
509 <span class="note"><xsl:apply-templates mode="text"/></span>
510 </p>
511 </xsl:when>
512 <xsl:when test="$collectionName = 'echo' and $hasLabel"></xsl:when>
513 <xsl:when test="$collectionName = 'tei'">
514 <xsl:choose>
515 <xsl:when test="contains($place, 'margin')">
516 <span>
517 <xsl:attribute name="class"><xsl:value-of select="concat('note ', $place)"/></xsl:attribute>
518 <xsl:apply-templates mode="text"/>
519 </span>
520 </xsl:when>
521 <xsl:otherwise>
522 <a>
523 <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute>
524 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute>
525 <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
526 <xsl:value-of select="$href"/>
527 </a>
528 </xsl:otherwise>
529 </xsl:choose>
530 </xsl:when>
531 <xsl:otherwise>
532 <span class="note"><xsl:apply-templates mode="text"/></span>
533 </xsl:otherwise>
534 </xsl:choose>
535 -->
536 </xsl:template>
537
538 <xsl:template match="emph" mode="text">
539 <xsl:variable name="style" select="@style"/>
540 <xsl:variable name="styleWithoutSC" select="replace($style, 'sc ', '')"/>
541 <xsl:variable name="text" select="string-join(., '')"/>
542 <xsl:variable name="length" select="string-length($text)"/>
543 <xsl:variable name="firstChar" select="substring($text, 1, 1)"/>
544 <xsl:variable name="first2Chars" select="substring($text, 1, 2)"/>
545 <xsl:variable name="restChars" select="substring($text, 2, $length)"/>
546 <xsl:variable name="first2CharsAreUppercase" select="upper-case($first2Chars) = $first2Chars"/>
547 <!-- an emph as first element in p and also an emph in s in p is recognized -->
548 <xsl:variable name="isFirstElementInP" select="(not(empty(./parent::*/parent::p)) and (empty(./parent::*/preceding-sibling::node()) and empty(./preceding-sibling::node()))) or (not(empty(./parent::p)) and empty(./preceding-sibling::node()))"/>
549 <xsl:variable name="rest">
550 <xsl:choose>
551 <xsl:when test="$length &lt; 2 or empty($length)"><xsl:value-of select="''"/></xsl:when>
552 <xsl:otherwise>
553 <xsl:choose>
554 <xsl:when test="not(empty(w))">
555 <a class="textPollux" href="{$polluxServiceName}?query={w/@form}&amp;queryDisplay={$text}&amp;language={w/@lang}&amp;outputFormat=html&amp;outputType=morphCompact&amp;outputType=dictFull"><xsl:value-of select="$restChars"/></a>
556 </xsl:when>
557 <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise>
558 </xsl:choose>
559 </xsl:otherwise>
560 </xsl:choose>
561 </xsl:variable>
562 <xsl:choose>
563 <xsl:when test="$collectionName = 'echo' and not(contains($style, 'sc'))">
564 <span class="{$style}"><xsl:apply-templates mode="text"/></span>
565 </xsl:when>
566 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $length = 1">
567 <span class="sc"><xsl:value-of select="$firstChar"/></span>
568 </xsl:when>
569 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and not($isFirstElementInP)">
570 <span class="sc"><xsl:apply-templates mode="text"/></span>
571 </xsl:when>
572 <!-- special case (see text() node below): first char dc, rest sc -->
573 <xsl:when test="$collectionName = 'echo' and $style = 'dc sc logic' and $first2CharsAreUppercase">
574 <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
575 </xsl:when>
576 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $first2CharsAreUppercase">
577 <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
578 </xsl:when>
579 <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and $first2CharsAreUppercase">
580 <span class="dc"><span class="{$styleWithoutSC}"><xsl:value-of select="$firstChar"/></span></span><span class="sc"><span class="{$styleWithoutSC}"><xsl:sequence select="$rest"/></span></span>
581 </xsl:when>
582 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and not($first2CharsAreUppercase)">
583 <span class="sc"><xsl:apply-templates mode="text"/></span>
584 </xsl:when>
585 <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and not($first2CharsAreUppercase)">
586 <span class="sc"><span class="{$styleWithoutSC}"><xsl:apply-templates mode="text"/></span></span>
587 </xsl:when>
588 <xsl:when test="$collectionName = 'archimedes' and $style != ''">
589 <span class="{$style}"><xsl:apply-templates mode="text"/></span>
590 </xsl:when>
591 <xsl:when test="$collectionName = 'archimedes' and $style = ''">
592 <span class="emph"><xsl:apply-templates mode="text"/></span>
593 </xsl:when>
594 <xsl:when test="$style != ''">
595 <span class="{$style}"><xsl:apply-templates mode="text"/></span>
596 </xsl:when>
597 <xsl:otherwise>
598 <span class="emph"><xsl:apply-templates mode="text"/></span>
599 </xsl:otherwise>
600 </xsl:choose>
601 </xsl:template>
602
603 <xsl:template match="foreign" mode="text">
604 <xsl:variable name="lang" select="@lang"/>
605 <xsl:variable name="xmllang" select="@xml:lang"/>
606 <xsl:variable name="language">
607 <xsl:choose>
608 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
609 <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
610 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
611 </xsl:choose>
612 </xsl:variable>
613 <span>
614 <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
615 <xsl:apply-templates mode="text"/>
616 </span>
617 </xsl:template>
618
619 <xsl:template match="q" mode="text">
620 <xsl:choose>
621 <xsl:when test="not(empty(@style))">
622 <span>
623 <xsl:attribute name="class"><xsl:value-of select="concat('q ', @style)"/></xsl:attribute>
624 <xsl:apply-templates mode="text"/>
625 </span>
626 </xsl:when>
627 <xsl:otherwise>
628 <span class="q"><xsl:apply-templates mode="text"/></span>
629 </xsl:otherwise>
630 </xsl:choose>
631 </xsl:template>
632
633 <xsl:template match="quote" mode="text">
634 <xsl:choose>
635 <xsl:when test="not(empty(@style))">
636 <div>
637 <xsl:attribute name="class"><xsl:value-of select="concat('quote ', @style)"/></xsl:attribute>
638 <xsl:apply-templates mode="text"/>
639 </div>
640 </xsl:when>
641 <xsl:otherwise>
642 <div class="quote"><xsl:apply-templates mode="text"/></div>
643 </xsl:otherwise>
644 </xsl:choose>
645 </xsl:template>
646
647 <xsl:template match="blockquote" mode="text">
648 <xsl:choose>
649 <xsl:when test="not(empty(@style))">
650 <div>
651 <xsl:attribute name="class"><xsl:value-of select="concat('blockquote ', @style)"/></xsl:attribute>
652 <xsl:apply-templates mode="text"/>
653 </div>
654 </xsl:when>
655 <xsl:otherwise>
656 <div class="blockquote"><xsl:apply-templates mode="text"/></div>
657 </xsl:otherwise>
658 </xsl:choose>
659 </xsl:template>
660
661 <xsl:template match="set-off" mode="text">
662 <xsl:choose>
663 <xsl:when test="not(empty(@style))">
664 <div>
665 <xsl:attribute name="class"><xsl:value-of select="concat('set-off ', @style)"/></xsl:attribute>
666 <xsl:apply-templates mode="text"/>
667 </div>
668 </xsl:when>
669 <xsl:otherwise>
670 <div class="set-off"><xsl:apply-templates mode="text"/></div>
671 </xsl:otherwise>
672 </xsl:choose>
673 </xsl:template>
674
675 <xsl:template match="reg" mode="text">
676 <xsl:choose>
677 <xsl:when test="not(empty(@style))">
678 <span>
679 <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @style)"/></xsl:attribute>
680 <xsl:apply-templates mode="text"/>
681 </span>
682 </xsl:when>
683 <xsl:otherwise>
684 <span class="reg"><xsl:apply-templates mode="text"/></span>
685 </xsl:otherwise>
686 </xsl:choose>
687 </xsl:template>
688
689 <xsl:template match="var" mode="text">
690 <xsl:choose>
691 <xsl:when test="not(empty(@style))">
692 <span>
693 <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @type, ' ', @style)"/></xsl:attribute>
694 <xsl:apply-templates mode="text"/>
695 </span>
696 </xsl:when>
697 <xsl:otherwise>
698 <span class="var">
699 <xsl:attribute name="class"><xsl:value-of select="concat('var ', @type)"/></xsl:attribute>
700 <xsl:apply-templates mode="text"/>
701 </span>
702 </xsl:otherwise>
703 </xsl:choose>
704 </xsl:template>
705
706 <xsl:template match="num" mode="text">
707 <xsl:choose>
708 <xsl:when test="not(empty(@style))">
709 <span>
710 <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
711 <span>
712 <xsl:attribute name="class"><xsl:value-of select="@style"/></xsl:attribute>
713 <xsl:apply-templates mode="text"/>
714 </span>
715 </span>
716 </xsl:when>
717 <xsl:otherwise>
718 <span class="num"><xsl:apply-templates mode="text"/></span>
719 </xsl:otherwise>
720 </xsl:choose>
721 </xsl:template>
722
723 <xsl:template match="gap" mode="text">
724 <xsl:variable name="extent" select="@extent"/>
725 <xsl:variable name="count">
726 <xsl:choose>
727 <xsl:when test="empty($extent)"><xsl:value-of select="number(3)"/></xsl:when>
728 <xsl:otherwise><xsl:value-of select="number($extent)"/></xsl:otherwise>
729 </xsl:choose>
730 </xsl:variable>
731 <xsl:variable name="gapChars" select="'...'"/>
732 <xsl:value-of select="concat('[', $gapChars, ']')"/><xsl:apply-templates mode="text"/>
733 </xsl:template>
734
735 <xsl:template match="anchor" mode="text">
736 <a><xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute><xsl:apply-templates mode="text"/></a>
737 </xsl:template>
738
739 <!-- GIS Elements -->
740 <xsl:template match="place" mode="text">
741 <span class="place">
742 <xsl:apply-templates mode="text"/>
743 </span>
744 </xsl:template>
745
746 <xsl:template match="time" mode="text">
747 <span class="time">
748 <xsl:apply-templates mode="text"/>
749 </span>
750 </xsl:template>
751
752 <xsl:template match="person" mode="text">
753 <span class="person">
754 <xsl:apply-templates mode="text"/>
755 </span>
756 </xsl:template>
757
758 <xsl:template match="event" mode="text">
759 <span class="event">
760 <xsl:apply-templates mode="text"/>
761 </span>
762 </xsl:template>
763
764 <!-- XHTML: remove the xhtml namespace -->
765 <xsl:template match="xhtml:*" mode="text">
766 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
767 <xsl:variable name="isTable" select="name() = 'table'"/>
768 <xsl:choose>
769 <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
770 <xsl:element name="{name()}" namespace="">
771 <xsl:copy-of select="@*"/>
772 <xsl:apply-templates mode="text"/>
773 </xsl:element>
774 </xsl:when>
775 <xsl:otherwise></xsl:otherwise>
776 </xsl:choose>
777 </xsl:template>
778
779 <xsl:template match="figure" mode="text">
780 <span class="figure">
781 <xsl:apply-templates mode="text"/>
782 </span>
783 </xsl:template>
784
785 <xsl:template match="caption" mode="text">
786 <span class="figureCaption"><xsl:apply-templates mode="text"/></span>
787 </xsl:template>
788
789 <xsl:template match="description" mode="text">
790 <span class="figureDescription"><xsl:apply-templates mode="text"/></span>
791 </xsl:template>
792
793 <xsl:template match="handwritten" mode="text">
794 <span class="handwritten"><xsl:apply-templates mode="text"/></span>
795 </xsl:template>
796
797
798 <!-- words -->
799 <xsl:template match="w" mode="text">
800 <xsl:variable name="wordLanguage" select="@lang"/>
801 <xsl:variable name="form" select="encode-for-uri(@form)"/>
802 <xsl:variable name="displayWord"><xsl:apply-templates mode="text"/></xsl:variable>
803 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/>
804 <a class="textPollux">
805 <xsl:attribute name="href"><xsl:value-of select="concat($polluxServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
806 <xsl:sequence select="$displayWord"/>
807 </a>
808 </xsl:template>
809
810 <xsl:template match="s" mode="text">
811 <span class="s">
812 <xsl:apply-templates mode="text"/>
813 </span>
814 </xsl:template>
815
816 <xsl:template match="text()" mode="text">
817 <xsl:value-of select="."/>
818 </xsl:template>
819
820 </xsl:stylesheet>