comparison software/mpdl-services/mpiwg-mpdl-xml/build/classes/de/mpg/mpiwg/berlin/mpdl/xml/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: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 exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo math mml svg xhtml"
16 >
17
18 <xsl:output method="xhtml" encoding="utf-8"/>
19
20 <xsl:param name="mode"></xsl:param>
21 <xsl:param name="normalization"></xsl:param>
22
23 <xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
24
25 <xsl:template match="*:echo">
26 <span class="page">
27 <xsl:apply-templates mode="text"/>
28 </span>
29 </xsl:template>
30
31 <xsl:template match="*:anchor|*:figure|*:caption|*:description|*:handwritten|*:place|*:person" mode="text">
32 <xsl:element name="span">
33 <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
34 <xsl:copy-of select="@*"/>
35 <xsl:apply-templates mode="text"/>
36 </xsl:element>
37 </xsl:template>
38
39 <xsl:template match="*:text" mode="text">
40 <xsl:apply-templates mode="text"/>
41 <!-- Notes -->
42 <!--
43 <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
44 <xsl:variable name="countBottomPlaces">
45 <xsl:value-of select="count($notes/note[contains(@position, 'bottom') or empty(string(@position))])"/>
46 </xsl:variable>
47 <xsl:if test="count($notes/*) > 0">
48 <div>
49 <xsl:choose>
50 <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
51 <hr class="notesBottom"/>
52 </xsl:when>
53 <xsl:otherwise></xsl:otherwise>
54 </xsl:choose>
55 <xsl:for-each select="$notes/echo:note">
56 <xsl:variable name="label" select="string(@xlink:label)"/>
57 <xsl:variable name="place" select="@position"/>
58 <xsl:variable name="uid" select="@uid"/>
59 <xsl:variable name="modificationDate" select="@modificationDate"/>
60 <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
61 <xsl:choose>
62 <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
63 <p>
64 <a>
65 <xsl:attribute name="name"><xsl:value-of select="$label"/></xsl:attribute>
66 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $label, 'ref')"/></xsl:attribute>
67 <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
68 <xsl:value-of select="$label"/>
69 </a>
70 <xsl:value-of select="': '"/>
71 <xsl:choose>
72 <xsl:when test="$uid = '' or empty($uid)">
73 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
74 </xsl:when>
75 <xsl:otherwise>
76 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
77 <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </p>
81 </xsl:when>
82 <xsl:otherwise></xsl:otherwise>
83 </xsl:choose>
84 </xsl:for-each>
85 </div>
86 </xsl:if>
87 -->
88 </xsl:template>
89
90 <xsl:template match="*:head" mode="text">
91 <xsl:variable name="class">
92 <xsl:value-of select="'head bf'"/>
93 </xsl:variable>
94 <p>
95 <span>
96 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
97 <xsl:apply-templates mode="text"/>
98 </span>
99 </p>
100 </xsl:template>
101
102 <!-- MathML -->
103 <xsl:template match="math:*" mode="text">
104 <xsl:element name="{name()}" namespace="">
105 <xsl:copy-of select="@*"/>
106 <xsl:apply-templates mode="text"/>
107 </xsl:element>
108 </xsl:template>
109
110 <!-- SVG -->
111 <xsl:template match="svg:*" mode="text">
112 <xsl:element name="{name()}" namespace="">
113 <xsl:copy-of select="@*"/>
114 <xsl:apply-templates mode="text"/>
115 </xsl:element>
116 </xsl:template>
117
118 <xsl:template match="*:div" mode="text">
119 <xsl:variable name="type" select="@type"/>
120 <xsl:variable name="level" select="@level"/>
121 <xsl:variable name="style" select="@style"/>
122 <xsl:variable name="border" select="@border"/>
123 <xsl:variable name="width" select="@width"/>
124 <xsl:variable name="note" select="note"/>
125 <xsl:variable name="figure" select="figure"/>
126 <xsl:variable name="floatClassValue">
127 <xsl:choose>
128 <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when>
129 <xsl:when test="not(empty($figure))"><xsl:value-of select="''"/></xsl:when>
130 <xsl:when test="$type = 'float'"><xsl:value-of select="'float left'"/></xsl:when>
131 <xsl:otherwise><xsl:value-of select="'float left'"/></xsl:otherwise>
132 </xsl:choose>
133 </xsl:variable>
134 <xsl:variable name="levelClassValue">
135 <xsl:choose>
136 <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when>
137 <xsl:when test="$level = '1'"><xsl:value-of select="'level one'"/></xsl:when>
138 <xsl:when test="$level = '2'"><xsl:value-of select="'level two'"/></xsl:when>
139 <xsl:when test="$level = '3'"><xsl:value-of select="'level three'"/></xsl:when>
140 <xsl:when test="$level = '4'"><xsl:value-of select="'level four'"/></xsl:when>
141 <xsl:when test="$level = '5'"><xsl:value-of select="'level five'"/></xsl:when>
142 <xsl:when test="$level = '6'"><xsl:value-of select="'level six'"/></xsl:when>
143 <xsl:when test="$level = '7'"><xsl:value-of select="'level seven'"/></xsl:when>
144 <xsl:when test="$level = '8'"><xsl:value-of select="'level eight'"/></xsl:when>
145 <xsl:when test="$level = '9'"><xsl:value-of select="'level nine'"/></xsl:when>
146 <xsl:when test="empty($level)"><xsl:value-of select="''"/></xsl:when>
147 <xsl:otherwise><xsl:value-of select="'level n'"/></xsl:otherwise>
148 </xsl:choose>
149 </xsl:variable>
150 <div>
151 <xsl:if test="not(empty($style))"><xsl:attribute name="style"><xsl:value-of select="$style"/></xsl:attribute></xsl:if>
152 <xsl:attribute name="class"><xsl:value-of select="concat($floatClassValue, ' ', $levelClassValue)"/></xsl:attribute>
153 <xsl:apply-templates mode="text"/>
154 </div>
155 </xsl:template>
156
157 <xsl:template match="*:p" mode="text">
158 <xsl:variable name="style" select="@style"/>
159 <xsl:variable name="class">
160 <xsl:value-of select="'p'"/>
161 </xsl:variable>
162 <xsl:choose>
163 <xsl:when test="not(empty($style))">
164 <div>
165 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
166 <span>
167 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
168 <xsl:apply-templates mode="text"/>
169 </span>
170 </div>
171 </xsl:when>
172 <xsl:otherwise>
173 <div>
174 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
175 <xsl:apply-templates mode="text"/>
176 </div>
177 </xsl:otherwise>
178 </xsl:choose>
179 </xsl:template>
180
181 <xsl:template match="*:pb" mode="text">
182 <xsl:element name="span">
183 <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
184 <xsl:copy-of select="@*"/>
185 <xsl:apply-templates mode="text"/>
186 </xsl:element>
187 </xsl:template>
188
189 <xsl:template match="*:lb" mode="text">
190 <br/><xsl:apply-templates mode="text"/>
191 </xsl:template>
192
193 <xsl:template match="*:cb" mode="text">
194 <br/><xsl:apply-templates mode="text"/>
195 </xsl:template>
196
197 <xsl:template match="*:expan" mode="text">
198 <xsl:choose>
199 <xsl:when test="not(empty(@style))">
200 <span>
201 <xsl:attribute name="class"><xsl:value-of select="concat('expan ', @style)"/></xsl:attribute>
202 <xsl:apply-templates mode="text"/>
203 </span>
204 </xsl:when>
205 <xsl:otherwise>
206 <span class="expan"><xsl:apply-templates mode="text"/></span>
207 </xsl:otherwise>
208 </xsl:choose>
209 </xsl:template>
210
211 <xsl:template match="*:note" mode="text">
212 <!--
213 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
214 <xsl:variable name="place"><xsl:value-of select="@position"/></xsl:variable>
215 <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/>
216 <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/>
217 <xsl:choose>
218 <xsl:when test="not($hasLabel) and not(empty($place))">
219 <span>
220 <xsl:attribute name="class"><xsl:value-of select="concat('note margin ', $place)"/></xsl:attribute>
221 <xsl:apply-templates mode="text"/>
222 </span>
223 </xsl:when>
224 <xsl:when test="not($hasLabel)">
225 <p>
226 <xsl:value-of select="'[Note]: '"/>
227 <span class="note"><xsl:apply-templates mode="text"/></span>
228 </p>
229 </xsl:when>
230 <xsl:when test="$hasLabel"></xsl:when>
231 <xsl:otherwise>
232 <span class="note"><xsl:apply-templates mode="text"/></span>
233 </xsl:otherwise>
234 </xsl:choose>
235 -->
236 </xsl:template>
237
238 <xsl:template match="*:emph" mode="text">
239 <xsl:variable name="style" select="@style"/>
240 <xsl:variable name="styleWithoutSC" select="replace($style, 'sc ', '')"/>
241 <xsl:variable name="text" select="string-join(., '')"/>
242 <xsl:variable name="length" select="string-length($text)"/>
243 <xsl:variable name="firstChar" select="substring($text, 1, 1)"/>
244 <xsl:variable name="first2Chars" select="substring($text, 1, 2)"/>
245 <xsl:variable name="restChars" select="substring($text, 2, $length)"/>
246 <xsl:variable name="first2CharsAreUppercase" select="upper-case($first2Chars) = $first2Chars"/>
247 <!-- an emph as first element in p and also an emph in s in p is recognized -->
248 <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()))"/>
249 <xsl:variable name="rest">
250 <xsl:choose>
251 <xsl:when test="$length &lt; 2 or empty($length)"><xsl:value-of select="''"/></xsl:when>
252 <xsl:otherwise>
253 <xsl:choose>
254 <xsl:when test="not(empty(w))">
255 <a class="dictionary" href="{$dictionaryServiceName}?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>
256 </xsl:when>
257 <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise>
258 </xsl:choose>
259 </xsl:otherwise>
260 </xsl:choose>
261 </xsl:variable>
262 <xsl:choose>
263 <xsl:when test="not(contains($style, 'sc'))">
264 <span class="{$style}"><xsl:apply-templates mode="text"/></span>
265 </xsl:when>
266 <xsl:when test="$style = 'sc' and $length = 1">
267 <span class="sc"><xsl:value-of select="$firstChar"/></span>
268 </xsl:when>
269 <xsl:when test="$style = 'sc' and not($isFirstElementInP)">
270 <span class="sc"><xsl:apply-templates mode="text"/></span>
271 </xsl:when>
272 <!-- special case (see text() node below): first char dc, rest sc -->
273 <xsl:when test="$style = 'dc sc logic' and $first2CharsAreUppercase">
274 <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
275 </xsl:when>
276 <xsl:when test="$style = 'sc' and $first2CharsAreUppercase">
277 <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
278 </xsl:when>
279 <xsl:when test="contains($style, 'sc') and $first2CharsAreUppercase">
280 <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>
281 </xsl:when>
282 <xsl:when test="$style = 'sc' and not($first2CharsAreUppercase)">
283 <span class="sc"><xsl:apply-templates mode="text"/></span>
284 </xsl:when>
285 <xsl:when test="contains($style, 'sc') and not($first2CharsAreUppercase)">
286 <span class="sc"><span class="{$styleWithoutSC}"><xsl:apply-templates mode="text"/></span></span>
287 </xsl:when>
288 <xsl:when test="$style != ''">
289 <span class="{$style}"><xsl:apply-templates mode="text"/></span>
290 </xsl:when>
291 <xsl:otherwise>
292 <span class="emph"><xsl:apply-templates mode="text"/></span>
293 </xsl:otherwise>
294 </xsl:choose>
295 </xsl:template>
296
297 <xsl:template match="*:foreign" mode="text">
298 <xsl:variable name="lang" select="@lang"/>
299 <xsl:variable name="xmllang" select="@xml:lang"/>
300 <xsl:variable name="language">
301 <xsl:choose>
302 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
303 <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
304 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
305 </xsl:choose>
306 </xsl:variable>
307 <span>
308 <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
309 <xsl:apply-templates mode="text"/>
310 </span>
311 </xsl:template>
312
313 <xsl:template match="*:q" mode="text">
314 <xsl:choose>
315 <xsl:when test="not(empty(@style))">
316 <span>
317 <xsl:attribute name="class"><xsl:value-of select="concat('q ', @style)"/></xsl:attribute>
318 <xsl:apply-templates mode="text"/>
319 </span>
320 </xsl:when>
321 <xsl:otherwise>
322 <span class="q"><xsl:apply-templates mode="text"/></span>
323 </xsl:otherwise>
324 </xsl:choose>
325 </xsl:template>
326
327 <xsl:template match="*:quote" mode="text">
328 <xsl:choose>
329 <xsl:when test="not(empty(@style))">
330 <div>
331 <xsl:attribute name="class"><xsl:value-of select="concat('quote ', @style)"/></xsl:attribute>
332 <xsl:apply-templates mode="text"/>
333 </div>
334 </xsl:when>
335 <xsl:otherwise>
336 <div class="quote"><xsl:apply-templates mode="text"/></div>
337 </xsl:otherwise>
338 </xsl:choose>
339 </xsl:template>
340
341 <xsl:template match="*:blockquote" mode="text">
342 <xsl:choose>
343 <xsl:when test="not(empty(@style))">
344 <div>
345 <xsl:attribute name="class"><xsl:value-of select="concat('blockquote ', @style)"/></xsl:attribute>
346 <xsl:apply-templates mode="text"/>
347 </div>
348 </xsl:when>
349 <xsl:otherwise>
350 <div class="blockquote"><xsl:apply-templates mode="text"/></div>
351 </xsl:otherwise>
352 </xsl:choose>
353 </xsl:template>
354
355 <xsl:template match="*:set-off" mode="text">
356 <xsl:choose>
357 <xsl:when test="not(empty(@style))">
358 <div>
359 <xsl:attribute name="class"><xsl:value-of select="concat('set-off ', @style)"/></xsl:attribute>
360 <xsl:apply-templates mode="text"/>
361 </div>
362 </xsl:when>
363 <xsl:otherwise>
364 <div class="set-off"><xsl:apply-templates mode="text"/></div>
365 </xsl:otherwise>
366 </xsl:choose>
367 </xsl:template>
368
369 <xsl:template match="*:reg" mode="text">
370 <xsl:choose>
371 <xsl:when test="not(empty(@style))">
372 <span>
373 <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @style)"/></xsl:attribute>
374 <xsl:apply-templates mode="text"/>
375 </span>
376 </xsl:when>
377 <xsl:otherwise>
378 <span class="reg"><xsl:apply-templates mode="text"/></span>
379 </xsl:otherwise>
380 </xsl:choose>
381 </xsl:template>
382
383 <xsl:template match="*:var" mode="text">
384 <xsl:choose>
385 <xsl:when test="not(empty(@style))">
386 <span>
387 <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @type, ' ', @style)"/></xsl:attribute>
388 <xsl:apply-templates mode="text"/>
389 </span>
390 </xsl:when>
391 <xsl:otherwise>
392 <span class="var">
393 <xsl:attribute name="class"><xsl:value-of select="concat('var ', @type)"/></xsl:attribute>
394 <xsl:apply-templates mode="text"/>
395 </span>
396 </xsl:otherwise>
397 </xsl:choose>
398 </xsl:template>
399
400 <xsl:template match="*:num" mode="text">
401 <xsl:choose>
402 <xsl:when test="not(empty(@style))">
403 <span>
404 <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
405 <span>
406 <xsl:attribute name="class"><xsl:value-of select="@style"/></xsl:attribute>
407 <xsl:apply-templates mode="text"/>
408 </span>
409 </span>
410 </xsl:when>
411 <xsl:otherwise>
412 <span class="num"><xsl:apply-templates mode="text"/></span>
413 </xsl:otherwise>
414 </xsl:choose>
415 </xsl:template>
416
417 <xsl:template match="*:gap" mode="text">
418 <xsl:variable name="extent" select="@extent"/>
419 <xsl:variable name="count">
420 <xsl:choose>
421 <xsl:when test="empty($extent)"><xsl:value-of select="number(3)"/></xsl:when>
422 <xsl:otherwise><xsl:value-of select="number($extent)"/></xsl:otherwise>
423 </xsl:choose>
424 </xsl:variable>
425 <xsl:variable name="gapChars" select="'...'"/>
426 <xsl:value-of select="concat('[', $gapChars, ']')"/><xsl:apply-templates mode="text"/>
427 </xsl:template>
428
429 <!-- XHTML: remove the xhtml namespace -->
430 <xsl:template match="xhtml:*" mode="text">
431 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
432 <xsl:variable name="isTable" select="name() = 'table'"/>
433 <xsl:choose>
434 <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
435 <xsl:element name="{name()}" namespace="">
436 <xsl:copy-of select="@*"/>
437 <xsl:apply-templates mode="text"/>
438 </xsl:element>
439 </xsl:when>
440 <xsl:otherwise></xsl:otherwise>
441 </xsl:choose>
442 </xsl:template>
443
444
445 <!-- words -->
446 <xsl:template match="*:w" mode="text">
447 <xsl:variable name="wordLanguage" select="@lang"/>
448 <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
449 <xsl:variable name="formNotUrlEncoded" select="string(@form)"/>
450 <xsl:variable name="formRegularized" select="string(@formRegularized)"/>
451 <xsl:variable name="formNormalized" select="string(@formNormalized)"/>
452 <xsl:variable name="lemmas" select="string(@lemmas)"/>
453 <xsl:variable name="dictionary" select="string(@dictionary)"/>
454 <xsl:variable name="displayWord">
455 <xsl:choose>
456 <xsl:when test="$normalization = 'orig'"><xsl:apply-templates mode="text"/></xsl:when>
457 <xsl:when test="$normalization = 'reg' and $formRegularized = ''"><xsl:apply-templates mode="text"/></xsl:when>
458 <xsl:when test="$normalization = 'reg' and $formRegularized != ''"><xsl:sequence select="$formRegularized"/></xsl:when>
459 <xsl:when test="$normalization = 'norm'"><xsl:apply-templates mode="text"/></xsl:when>
460 <xsl:otherwise><xsl:apply-templates mode="text"/></xsl:otherwise>
461 </xsl:choose>
462 </xsl:variable>
463 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/>
464 <xsl:choose>
465 <xsl:when test="$dictionary = 'true' and $mode = 'tokenized'">
466 <a class="dictionary">
467 <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>
468 <xsl:sequence select="$displayWord"/>
469 </a>
470 </xsl:when>
471 <xsl:otherwise><xsl:sequence select="$displayWord"/></xsl:otherwise>
472 </xsl:choose>
473 </xsl:template>
474
475 <xsl:template match="*:s" mode="text">
476 <span class="s">
477 <xsl:apply-templates mode="text"/>
478 </span>
479 </xsl:template>
480
481 <xsl:template match="text()" mode="text">
482 <xsl:value-of select="."/>
483 </xsl:template>
484
485 </xsl:stylesheet>