Mercurial > hg > mpdl-group
comparison software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children | d2a1c14fde31 |
comparison
equal
deleted
inserted
replaced
6:2396a569e446 | 7:5589d865af7a |
---|---|
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:mpdl="http://www.mpiwg-berlin.mpg.de/ns/mpdl" | |
9 xmlns:mpdl-util="http://www.mpiwg-berlin.mpg.de/ns/mpdl/util" | |
10 xmlns:text="http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" | |
11 xmlns:dc="http://purl.org/dc/elements/1.1/" | |
12 xmlns:dcterms="http://purl.org/dc/terms" | |
13 xmlns:echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/" | |
14 xmlns:mml="http://www.w3.org/1998/Math/MathML" | |
15 xmlns:xhtml="http://www.w3.org/1999/xhtml"> | |
16 | |
17 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" /> | |
18 <xsl:import href="/db/mpdl/presentation/functions-text.xsl" /> | |
19 <xsl:import href="/db/mpdl/presentation/functions-util.xsl" /> | |
20 | |
21 <xsl:output method="xhtml" encoding="utf-8"/> | |
22 | |
23 <xsl:variable name="mode" select="/result/page/mode"/> | |
24 <xsl:variable name="language" select="/result/document-description/language"/> | |
25 <xsl:variable name="sn" select="number(/result/page/sentence-number)"/> | |
26 <xsl:variable name="digilibAvailable" select="/result/page/digilib-available"/> | |
27 <xsl:variable name="options" select="/result/page/options"/> | |
28 <xsl:variable name="topPB" select="subsequence(//pb, 1, 1)"/> | |
29 <xsl:variable name="firstSentence" select="subsequence(//s, 1, 1)"/> | |
30 <xsl:variable name="highlightQuery" select="string(/result/page/highlights/query)"/> | |
31 <xsl:variable name="highlightQueryTermsTemp" select="string-join(text:translateLuceneToTerms($highlightQuery), '')" as="xs:string"/> | |
32 <xsl:variable name="highlightQueryWords" select="string(/result/page/highlights/words)"/> | |
33 <xsl:variable name="highlightQueryTerms" select="text:removeDuplicates($highlightQueryTermsTemp, $highlightQueryWords)"/> | |
34 | |
35 <xsl:template match="result"> | |
36 <xsl:for-each select="page"> | |
37 <xsl:variable name="documentUri" select="/result/document-description/uri"/> | |
38 <xsl:variable name="documentName" select="/result/document-description/document-name"/> | |
39 <xsl:variable name="countPages" select="/result/document-description/count-pages"/> | |
40 <xsl:variable name="countPlaces" select="/result/document-description/count-places"/> | |
41 <xsl:variable name="countTocEntries" select="/result/document-description/count-toc-entries"/> | |
42 <xsl:variable name="countFigureEntries" select="/result/document-description/count-figure-entries"/> | |
43 <xsl:variable name="pageHeader" select="header"/> | |
44 <xsl:variable name="pageNumber" select="number(number)"/> | |
45 <xsl:variable name="pageNumberOrig" select="number-orig"/> | |
46 <xsl:variable name="documentValue" select="concat('document=', $documentUri)"/> | |
47 <xsl:variable name="pnValue" select="concat('pn=', $pageNumber)"/> | |
48 <xsl:variable name="modeValue" select="concat('mode=', $mode)"/> | |
49 <div class="page"> | |
50 <div class="pageMeta"> | |
51 <div class="countPages"><xsl:value-of select="$countPages"/></div> | |
52 <div class="countPlaces"><xsl:value-of select="$countPlaces"/></div> | |
53 <div class="countTocEntries"><xsl:value-of select="$countTocEntries"/></div> | |
54 <div class="countFigureEntries"><xsl:value-of select="$countFigureEntries"/></div> | |
55 <div class="pageNumber"><xsl:value-of select="$pageNumber"/></div> | |
56 <!-- test ob die Zahl gerade oder ungerade ist --> | |
57 <xsl:choose> | |
58 <xsl:when test="$pageNumberOrig = ''"></xsl:when> | |
59 <xsl:otherwise><div class="pageNumberOrig"><xsl:value-of select="$pageNumberOrig"/></div></xsl:otherwise> | |
60 </xsl:choose> | |
61 <xsl:if test="$pageHeader != ''"> | |
62 <div class="pageHeaderTitle"><xsl:value-of select="$pageHeader"/></div> | |
63 </xsl:if> | |
64 </div> | |
65 <div class="pageContent"> | |
66 <xsl:for-each select="content"> | |
67 <xsl:variable name="contentStr" select="normalize-space(string(.))"/> | |
68 <xsl:variable name="figures" select=".//figure|.//handwritten"/> | |
69 <xsl:if test="$contentStr = '' and empty($figures)"> | |
70 <div class="emptyPage"><xsl:value-of select="'[Empty page]'"/></div> | |
71 </xsl:if> | |
72 <xsl:choose> | |
73 <xsl:when test="$mode = 'text' or $mode = 'textPollux' or $mode = 'gis'"> | |
74 <xsl:apply-templates mode="text"/> | |
75 </xsl:when> | |
76 <xsl:when test="$mode = 'xml'"> | |
77 <xsl:apply-templates mode="xml"/> | |
78 </xsl:when> | |
79 <xsl:when test="$mode = 'image'"> | |
80 <xsl:variable name="imageAvailable" select="/result/page/image-available"/> | |
81 <xsl:variable name="imageFileName" select="/result/page/image-file-name"/> | |
82 <xsl:variable name="linkImageEcho" select="/result/page/image-echo"/> | |
83 <xsl:variable name="linkImageScaler" select="/result/page/image-scaler"/> | |
84 <xsl:variable name="imageHeight" select="600"/> | |
85 <xsl:choose> | |
86 <xsl:when test="$digilibAvailable = 'true' and $imageAvailable = 'true'"> | |
87 <div style="height:{$imageHeight}px; margin-left:10px; margin-right:10px; border: 1px;"> | |
88 <a href="{$linkImageEcho}"><img alt="Page image: {$linkImageScaler}" src="{$linkImageScaler}&dh={$imageHeight}"/></a> | |
89 </div> | |
90 </xsl:when> | |
91 <xsl:when test="$digilibAvailable = 'true' and $imageAvailable = 'false'"> | |
92 <div style="height:{$imageHeight}px; margin-left:10px; margin-right:10px; border:1px dashed;"> | |
93 <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> | |
94 Page image: <br/> | |
95 <br/> | |
96 <xsl:value-of select="$imageFileName"/> , page <xsl:value-of select="$pageNumber"/> | |
97 <br/><br/> | |
98 not scanned | |
99 </div> | |
100 </xsl:when> | |
101 <xsl:when test="$digilibAvailable = 'false'"> | |
102 <div style="height:{$imageHeight}px; margin-left:10px; margin-right:10px; border:1px dashed;"> | |
103 <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> | |
104 Could not fetch: <br/> | |
105 <br/> | |
106 <xsl:value-of select="$imageFileName"/> , page <xsl:value-of select="$pageNumber"/> | |
107 <br/><br/> | |
108 from nausikaa2.rz-berlin.mpg.de: please try again later | |
109 </div> | |
110 </xsl:when> | |
111 <xsl:otherwise></xsl:otherwise> | |
112 </xsl:choose> | |
113 </xsl:when> | |
114 <xsl:otherwise></xsl:otherwise> | |
115 </xsl:choose> | |
116 </xsl:for-each> | |
117 </div> | |
118 </div> | |
119 </xsl:for-each> | |
120 </xsl:template> | |
121 | |
122 <xsl:template match="attribute()|element()|text()|comment()|processing-instruction()" mode="xml"> | |
123 <xsl:copy> | |
124 <xsl:apply-templates select="attribute()|element()|text()|comment()|processing-instruction()"/> | |
125 </xsl:copy> | |
126 </xsl:template> | |
127 | |
128 <xsl:template match="element()|comment()|processing-instruction()" mode="xml"> | |
129 <xsl:variable name="elementName" select="name()"/> | |
130 <xsl:variable name="elementPresentation"> | |
131 <xsl:choose> | |
132 <xsl:when test="element() = node() or text() != '' or self::comment() or self::processing-instruction()"> | |
133 <xsl:value-of select="'<'"/> | |
134 <span class="xml elementName"><xsl:value-of select="$elementName"/></span> | |
135 <xsl:apply-templates select="attribute()" mode="xml"/> | |
136 <xsl:value-of select="'>'"/> | |
137 <xsl:apply-templates select="element()|text()|comment()|processing-instruction()" mode="xml"/> | |
138 <xsl:value-of select="'</'"/> | |
139 <span class="xml elementName"><xsl:value-of select="$elementName"/></span> | |
140 <xsl:value-of select="'>'"/> | |
141 </xsl:when> | |
142 <xsl:otherwise> | |
143 <xsl:value-of select="'<'"/> | |
144 <span class="xml elementName"><xsl:value-of select="$elementName"/></span> | |
145 <xsl:apply-templates select="attribute()" mode="xml"/> | |
146 <xsl:value-of select="'/>'"/> | |
147 </xsl:otherwise> | |
148 </xsl:choose> | |
149 </xsl:variable> | |
150 <xsl:variable name="actualSN"> | |
151 <xsl:choose> | |
152 <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> | |
153 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> | |
154 </xsl:choose> | |
155 </xsl:variable> | |
156 <xsl:choose> | |
157 <!-- Show the sentence in color light grey if it is given as sn --> | |
158 <xsl:when test="$elementName = 's' and $sn >= 0 and $sn = $actualSN"> | |
159 <ul class="xml element highlight"> | |
160 <a name="sn{$actualSN}"></a><xsl:sequence select="$elementPresentation"/> | |
161 </ul> | |
162 </xsl:when> | |
163 <xsl:when test="$elementName = 's' and $sn != $actualSN"> | |
164 <ul class="xml element"> | |
165 <a name="sn{$actualSN}"></a><xsl:sequence select="$elementPresentation"/> | |
166 </ul> | |
167 </xsl:when> | |
168 <xsl:otherwise> | |
169 <ul class="xml element"> | |
170 <xsl:sequence select="$elementPresentation"/> | |
171 </ul> | |
172 </xsl:otherwise> | |
173 </xsl:choose> | |
174 </xsl:template> | |
175 | |
176 <xsl:template match="attribute()" mode="xml"> | |
177 <xsl:variable name="attributeName" select="name()"/> | |
178 <span class="xml attributeName"> | |
179 <xsl:value-of select="' '"/> | |
180 <xsl:value-of select="$attributeName"/> | |
181 </span> | |
182 <xsl:value-of select="'="'"/> | |
183 <span class="xml attributeValue"><xsl:value-of select="."/></span><xsl:value-of select="'"'"/> | |
184 <xsl:apply-templates select="attribute()" mode="xml"/> | |
185 </xsl:template> | |
186 | |
187 <xsl:template match="text()" mode="xml"> | |
188 <xsl:variable name="parentS" select="./ancestor::s"/> | |
189 <xsl:variable name="actualSN"> | |
190 <xsl:choose> | |
191 <xsl:when test="$parentS = $firstSentence and ($topPB >> $parentS)">0</xsl:when> | |
192 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> | |
193 </xsl:choose> | |
194 </xsl:variable> | |
195 <xsl:choose> | |
196 <xsl:when test="$highlightQuery != '' and $sn >= 0 and $sn = $actualSN"> | |
197 <xsl:sequence select="text:highlight(string(.), $highlightQueryTerms, $highlightQueryWords, 'false')"/> | |
198 </xsl:when> | |
199 <xsl:otherwise> | |
200 <xsl:value-of select="."/> | |
201 </xsl:otherwise> | |
202 </xsl:choose> | |
203 </xsl:template> | |
204 | |
205 | |
206 <!-- variables used by templates in mode "text" --> | |
207 <xsl:variable name="collectionName" select="/result/document-description/collection-name"/> | |
208 <xsl:variable name="documentUri" select="/result/document-description/uri"/> | |
209 <xsl:variable name="documentIdentifier" select="/result/document-description/identifier"/> | |
210 <xsl:variable name="pageNumber" select="/result/page/number"/> | |
211 <xsl:variable name="firstFigurePosition" select="/result/page/firstFigurePosition"/> | |
212 <xsl:variable name="figuresImageDirectory" select="/result/page/figures-image-directory"/> | |
213 <xsl:variable name="figures" select="/result/page/figures"/> | |
214 <xsl:variable name="handwritten" select="/result/page/handwritten"/> | |
215 <xsl:variable name="tables" select="/result/page/tables"/> | |
216 <xsl:variable name="notes" select="/result/page/notes"/> | |
217 <xsl:variable name="charNorm" select="/result/page/character-normalization"/> | |
218 | |
219 <xsl:template match="text" mode="text"> | |
220 <xsl:apply-templates mode="text"/> | |
221 <!-- Notes --> | |
222 <xsl:if test="$collectionName = 'archimedes' and count($notes/*) > 0"> | |
223 <div> | |
224 <hr class="notesBottom"/> | |
225 <xsl:for-each select="$notes/note"> | |
226 <xsl:variable name="notePos" select="position()"/> | |
227 <xsl:variable name="label" select="$notePos"/> | |
228 <xsl:variable name="uid" select="@uid"/> | |
229 <xsl:variable name="modificationDate" select="@modificationDate"/> | |
230 <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/> | |
231 <p> | |
232 <a> | |
233 <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute> | |
234 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute> | |
235 <xsl:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/> | |
236 </a> | |
237 <xsl:value-of select="': '"/> | |
238 <xsl:choose> | |
239 <xsl:when test="$uid = '' or empty($uid)"> | |
240 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span> | |
241 </xsl:when> | |
242 <xsl:otherwise> | |
243 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span> | |
244 <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/> | |
245 </xsl:otherwise> | |
246 </xsl:choose> | |
247 </p> | |
248 </xsl:for-each> | |
249 </div> | |
250 </xsl:if> | |
251 <xsl:if test="$collectionName = 'echo' and count($notes/*) > 0"> | |
252 <div> | |
253 <hr class="notesBottom"/> | |
254 <xsl:for-each select="$notes/echo:note"> | |
255 <xsl:variable name="label" select="string(@xlink:label)"/> | |
256 <xsl:variable name="uid" select="@uid"/> | |
257 <xsl:variable name="modificationDate" select="@modificationDate"/> | |
258 <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/> | |
259 <p> | |
260 <a> | |
261 <xsl:attribute name="name"><xsl:value-of select="$label"/></xsl:attribute> | |
262 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $label, 'ref')"/></xsl:attribute> | |
263 <xsl:value-of select="concat('[↑ ', $label, ']')"/> | |
264 </a> | |
265 <xsl:value-of select="': '"/> | |
266 <xsl:choose> | |
267 <xsl:when test="$uid = '' or empty($uid)"> | |
268 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span> | |
269 </xsl:when> | |
270 <xsl:otherwise> | |
271 <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span> | |
272 <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/> | |
273 </xsl:otherwise> | |
274 </xsl:choose> | |
275 </p> | |
276 </xsl:for-each> | |
277 </div> | |
278 </xsl:if> | |
279 </xsl:template> | |
280 | |
281 <xsl:template match="head" mode="text"> | |
282 <p class="bf center"><xsl:apply-templates mode="text"/></p> | |
283 </xsl:template> | |
284 | |
285 <xsl:template match="div" mode="text"> | |
286 <xsl:variable name="type" select="@type"/> | |
287 <xsl:variable name="level" select="@level"/> | |
288 <xsl:variable name="style" select="@style"/> | |
289 <xsl:variable name="border" select="@border"/> | |
290 <xsl:variable name="width" select="@width"/> | |
291 <xsl:variable name="note" select="note"/> | |
292 <xsl:variable name="figure" select="figure"/> | |
293 <xsl:variable name="floatClassValue"> | |
294 <xsl:choose> | |
295 <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when> | |
296 <xsl:when test="not(empty($figure))"><xsl:value-of select="''"/></xsl:when> | |
297 <xsl:when test="$type = 'float'"><xsl:value-of select="'float left'"/></xsl:when> | |
298 <xsl:otherwise><xsl:value-of select="'float left'"/></xsl:otherwise> | |
299 </xsl:choose> | |
300 </xsl:variable> | |
301 <xsl:variable name="levelClassValue"> | |
302 <xsl:choose> | |
303 <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when> | |
304 <xsl:when test="$level = '1'"><xsl:value-of select="'level one'"/></xsl:when> | |
305 <xsl:when test="$level = '2'"><xsl:value-of select="'level two'"/></xsl:when> | |
306 <xsl:when test="$level = '3'"><xsl:value-of select="'level three'"/></xsl:when> | |
307 <xsl:when test="$level = '4'"><xsl:value-of select="'level four'"/></xsl:when> | |
308 <xsl:when test="$level = '5'"><xsl:value-of select="'level five'"/></xsl:when> | |
309 <xsl:when test="$level = '6'"><xsl:value-of select="'level six'"/></xsl:when> | |
310 <xsl:when test="$level = '7'"><xsl:value-of select="'level seven'"/></xsl:when> | |
311 <xsl:when test="$level = '8'"><xsl:value-of select="'level eight'"/></xsl:when> | |
312 <xsl:when test="$level = '9'"><xsl:value-of select="'level nine'"/></xsl:when> | |
313 <xsl:when test="empty($level)"><xsl:value-of select="''"/></xsl:when> | |
314 <xsl:otherwise><xsl:value-of select="'level n'"/></xsl:otherwise> | |
315 </xsl:choose> | |
316 </xsl:variable> | |
317 <div> | |
318 <xsl:if test="not(empty($style))"><xsl:attribute name="style"><xsl:value-of select="$style"/></xsl:attribute></xsl:if> | |
319 <xsl:attribute name="class"><xsl:value-of select="concat($floatClassValue, ' ', $levelClassValue)"/></xsl:attribute> | |
320 <xsl:apply-templates mode="text"/> | |
321 </div> | |
322 </xsl:template> | |
323 | |
324 <xsl:template match="p" mode="text"> | |
325 <xsl:variable name="style" select="@style"/> | |
326 <p> | |
327 <xsl:if test="not(empty($style))"> | |
328 <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute> | |
329 </xsl:if> | |
330 <xsl:apply-templates mode="text"/> | |
331 </p> | |
332 </xsl:template> | |
333 | |
334 <xsl:template match="lb" mode="text"> | |
335 <xsl:variable name="withoutLBs"> | |
336 <xsl:choose> | |
337 <xsl:when test="contains($options, 'withoutLBs')"><xsl:value-of select="'true'"/></xsl:when> | |
338 <xsl:otherwise><xsl:value-of select="'false'"/></xsl:otherwise> | |
339 </xsl:choose> | |
340 </xsl:variable> | |
341 <xsl:if test="$withoutLBs = 'false'"><br/></xsl:if> | |
342 <xsl:apply-templates mode="text"/> | |
343 </xsl:template> | |
344 | |
345 <xsl:template match="cb" mode="text"> | |
346 <br/><xsl:apply-templates mode="text"/> | |
347 </xsl:template> | |
348 | |
349 <xsl:template match="expan" mode="text"> | |
350 <xsl:apply-templates mode="text"/><xsl:text> </xsl:text> | |
351 </xsl:template> | |
352 | |
353 <xsl:template match="note" mode="text"> | |
354 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/> | |
355 <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/> | |
356 <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/> | |
357 <xsl:choose> | |
358 <xsl:when test="$collectionName = 'archimedes'"> | |
359 <a> | |
360 <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute> | |
361 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute> | |
362 <xsl:attribute name="class"><xsl:value-of select="'super'"/></xsl:attribute> | |
363 <xsl:value-of select="concat(' ↓ (', $href, ') ')"/> | |
364 </a> | |
365 </xsl:when> | |
366 <xsl:when test="$collectionName = 'echo' and not($hasLabel)"> | |
367 <p> | |
368 <xsl:value-of select="'[Note]: '"/> | |
369 <span class="note"><xsl:apply-templates mode="text"/></span> | |
370 </p> | |
371 </xsl:when> | |
372 <xsl:otherwise></xsl:otherwise> | |
373 </xsl:choose> | |
374 </xsl:template> | |
375 | |
376 <xsl:template match="emph" mode="text"> | |
377 <xsl:variable name="class" select="@class"/> | |
378 <xsl:variable name="style" select="@style"/> | |
379 <xsl:variable name="text" select="string-join(., '')"/> | |
380 <xsl:variable name="length" select="string-length($text)"/> | |
381 <xsl:variable name="firstChar" select="substring($text, 1, 1)"/> | |
382 <xsl:variable name="first2Chars" select="substring($text, 1, 2)"/> | |
383 <xsl:variable name="restChars" select="substring($text, 2, $length)"/> | |
384 <xsl:variable name="first2CharsAreUppercase" select="upper-case($first2Chars) = $first2Chars"/> | |
385 <xsl:variable name="rest"> | |
386 <xsl:choose> | |
387 <xsl:when test="$length < 2 or empty($length)"><xsl:value-of select="''"/></xsl:when> | |
388 <xsl:otherwise> | |
389 <xsl:choose> | |
390 <xsl:when test="not(empty(w))"> | |
391 <a class="textPollux" href="lt/wordInfo.xql?language={w/@lang}&word={w/@form}&output=html"><xsl:value-of select="$restChars"/></a> | |
392 </xsl:when> | |
393 <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise> | |
394 </xsl:choose> | |
395 </xsl:otherwise> | |
396 </xsl:choose> | |
397 </xsl:variable> | |
398 <xsl:if test="$collectionName = 'echo' and not(contains($class, 'sc'))"><span class="{$class} {$style}"><xsl:apply-templates mode="text"/></span></xsl:if> | |
399 <xsl:if test="$collectionName = 'echo' and contains($class, 'sc') and $first2CharsAreUppercase"><span class="dc {$style}"><xsl:value-of select="$firstChar"/></span><span class="{$class} {$style}"><xsl:sequence select="$rest"/></span></xsl:if> | |
400 <xsl:if test="$collectionName = 'echo' and contains($class, 'sc') and not($first2CharsAreUppercase)"><span class="{$class} {$style}"><xsl:apply-templates mode="text"/></span></xsl:if> | |
401 <xsl:if test="$collectionName = 'archimedes'"><xsl:apply-templates mode="text"/></xsl:if> | |
402 </xsl:template> | |
403 | |
404 <xsl:template match="ref" mode="text"> | |
405 <span class="ref"><xsl:apply-templates mode="text"/></span> | |
406 </xsl:template> | |
407 | |
408 <xsl:template match="foreign" mode="text"> | |
409 <xsl:variable name="lang" select="@lang"/> | |
410 <xsl:variable name="xmllang" select="@xml:lang"/> | |
411 <xsl:variable name="language"> | |
412 <xsl:choose> | |
413 <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when> | |
414 <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when> | |
415 <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise> | |
416 </xsl:choose> | |
417 </xsl:variable> | |
418 <span> | |
419 <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute> | |
420 <xsl:apply-templates mode="text"/> | |
421 </span> | |
422 </xsl:template> | |
423 | |
424 <xsl:template match="q" mode="text"> | |
425 <div class="q"><xsl:apply-templates mode="text"/></div> | |
426 </xsl:template> | |
427 | |
428 <xsl:template match="quote" mode="text"> | |
429 <div class="quote"><xsl:apply-templates mode="text"/></div> | |
430 </xsl:template> | |
431 | |
432 <xsl:template match="blockquote" mode="text"> | |
433 <div class="blockquote"><xsl:apply-templates mode="text"/></div> | |
434 </xsl:template> | |
435 | |
436 <xsl:template match="set-off" mode="text"> | |
437 <div class="set-off"><xsl:apply-templates mode="text"/></div> | |
438 </xsl:template> | |
439 | |
440 <xsl:template match="reg" mode="text"> | |
441 <span class="reg"> | |
442 <xsl:apply-templates mode="text"/> | |
443 </span> | |
444 </xsl:template> | |
445 | |
446 <xsl:template match="var" mode="text"> | |
447 <xsl:variable name="type" select="@type"/> | |
448 <span class="var"> | |
449 <xsl:attribute name="class"><xsl:value-of select="concat('var ', $type)"/></xsl:attribute> | |
450 <xsl:apply-templates mode="text"/> | |
451 </span> | |
452 </xsl:template> | |
453 | |
454 <xsl:template match="num" mode="text"> | |
455 <span class="num"><xsl:apply-templates mode="text"/></span> | |
456 </xsl:template> | |
457 | |
458 <xsl:template match="gap" mode="text"> | |
459 <xsl:variable name="extent" select="@extent"/> | |
460 <xsl:variable name="count"> | |
461 <xsl:choose> | |
462 <xsl:when test="empty($extent)"><xsl:value-of select="number(3)"/></xsl:when> | |
463 <xsl:otherwise><xsl:value-of select="number($extent)"/></xsl:otherwise> | |
464 </xsl:choose> | |
465 </xsl:variable> | |
466 <xsl:variable name="gapChars" select="text:nchars($count, '.')"/> | |
467 <xsl:value-of select="concat('[', $gapChars, ']')"/><xsl:apply-templates mode="text"/> | |
468 </xsl:template> | |
469 | |
470 <xsl:template match="anchor" mode="text"> | |
471 <xsl:variable name="type" select="@type"/> | |
472 <xsl:variable name="href" select="@xlink:href"/> | |
473 <xsl:choose> | |
474 <xsl:when test="$type = 'figure'"> | |
475 <xsl:variable name="figure" select="$figures/echo:figure[@xlink:label = $href]"/> | |
476 <xsl:variable name="figureFileName"> | |
477 <xsl:choose> | |
478 <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="replace($figure/@xlink:href, '/', '.')"/></xsl:when> | |
479 <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$figure/echo:image/@file"/></xsl:when> | |
480 <xsl:otherwise><xsl:value-of select="$figure/echo:image/@file"/></xsl:otherwise> | |
481 </xsl:choose> | |
482 </xsl:variable> | |
483 <xsl:variable name="figureNumber"> | |
484 <xsl:choose> | |
485 <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="$firstFigurePosition + count($figure/preceding::figure)"/></xsl:when> | |
486 <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:when> | |
487 <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::echo:figure[empty(@xlink:label)]) + count(./preceding::echo:anchor[@type = 'figure'])"/></xsl:otherwise> | |
488 </xsl:choose> | |
489 </xsl:variable> | |
490 <xsl:variable name="figureCaption" select="string-join($figure/echo:caption/text(), ' ')"/> | |
491 <xsl:variable name="figureDescription" select="string-join($figure/echo:description/text(), ' ')"/> | |
492 <xsl:variable name="figureVariables" select="string-join($figure/echo:variables/text(), ' ')"/> | |
493 <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float right')"/> | |
494 </xsl:when> | |
495 <xsl:when test="$type = 'handwritten'"> | |
496 <xsl:variable name="hw" select="$handwritten/echo:handwritten[@xlink:label = $href]"/> | |
497 <xsl:variable name="hwFileName" select="$hw/@file"/> | |
498 <xsl:variable name="hwHref" select="$hw/@xlink:href"/> | |
499 <xsl:sequence select="mpdl:showHandwritten($hwFileName, $hwHref)"/> | |
500 </xsl:when> | |
501 <xsl:when test="$type = 'table'"> | |
502 <xsl:variable name="table" select="$tables/xhtml:table[@xlink:label = $href]"/> | |
503 <xsl:sequence select="mpdl-util:copyWithoutNamespace($table)"/> | |
504 </xsl:when> | |
505 <xsl:when test="$type = 'note'"> | |
506 <a> | |
507 <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute> | |
508 <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute> | |
509 <xsl:attribute name="class"><xsl:value-of select="'super'"/></xsl:attribute> | |
510 <xsl:value-of select="concat('↓ (', $href, ')')"/> | |
511 </a> | |
512 </xsl:when> | |
513 <xsl:otherwise><a><xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>Anchor of type: <xsl:value-of select="@type"/>, href: <xsl:value-of select="@xlink:href"/></a></xsl:otherwise> | |
514 </xsl:choose> | |
515 </xsl:template> | |
516 | |
517 <!-- GIS Elements --> | |
518 <xsl:template match="place" mode="text"> | |
519 <xsl:variable name="actualSN"> | |
520 <xsl:choose> | |
521 <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> | |
522 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> | |
523 </xsl:choose> | |
524 </xsl:variable> | |
525 <xsl:variable name="id" select="@id"/> | |
526 <xsl:variable name="echoDocDir" select="replace($figuresImageDirectory, '(.*)/.*$', '$1')"/> | |
527 <xsl:variable name="echoDocDirTokenized" select="tokenize($echoDocDir, '/')"/> | |
528 <xsl:variable name="echoDocDirNameSize" select="count($echoDocDirTokenized)"/> | |
529 <xsl:variable name="echoDoc" select="string(subsequence($echoDocDirTokenized, $echoDocDirNameSize))"/> | |
530 <xsl:variable name="docStrOld" select="concat('http://echo.mpiwg-berlin.mpg.de/ECHOdocuView?url=', $echoDocDir, '&pn=', $pageNumber, '&sn=', $actualSN, '&viewMode=gis')"/> | |
531 <xsl:variable name="docStr" select="concat('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=', $documentUri, '&mode=gis', '&pn=', $pageNumber, '&sn=', $actualSN)"/> | |
532 <xsl:variable name="docBase64Coded" select="saxon:string-to-base64Binary($docStr, 'utf8')"/> | |
533 <xsl:variable name="href" select="concat('http://chinagis.mpiwg-berlin.mpg.de/chinagis/REST/db/mpdl/', $echoDoc, '?id=', $id, '&doc=', $docBase64Coded, '&format=gis')"/> | |
534 <xsl:choose> | |
535 <xsl:when test="$mode = 'textPollux'"> | |
536 <xsl:variable name="baseUrlLex" select="'http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/'"/> | |
537 <xsl:variable name="wordLanguage" select="string-join(w[1]/@lang, '')"/> | |
538 <xsl:variable name="form" select="string-join(w/@form, '')"/> | |
539 <xsl:variable name="wordStr" select="string-join(w, '')"/> | |
540 <xsl:variable name="lexHref"> | |
541 <xsl:if test="not(empty(w))"> | |
542 <xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&word=', $form, '&output=html', '&placeHref=', encode-for-uri($href))"/> | |
543 </xsl:if> | |
544 <xsl:if test="empty(w)"> | |
545 <xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?type=place', '&output=html', '&placeHref=', encode-for-uri($href))"/> | |
546 </xsl:if> | |
547 </xsl:variable> | |
548 <span class="place"> | |
549 <a class="textPollux"><xsl:attribute name="href"><xsl:value-of select="$lexHref"/></xsl:attribute><xsl:value-of select="$wordStr"/></a> | |
550 </span> | |
551 </xsl:when> | |
552 <xsl:otherwise> | |
553 <span class="place"> | |
554 <xsl:apply-templates mode="text"/> | |
555 </span> | |
556 </xsl:otherwise> | |
557 </xsl:choose> | |
558 </xsl:template> | |
559 | |
560 <xsl:template match="time" mode="text"> | |
561 <span class="time"> | |
562 <xsl:apply-templates mode="text"/> | |
563 </span> | |
564 </xsl:template> | |
565 | |
566 <xsl:template match="person" mode="text"> | |
567 <span class="person"> | |
568 <xsl:apply-templates mode="text"/> | |
569 </span> | |
570 </xsl:template> | |
571 | |
572 <xsl:template match="event" mode="text"> | |
573 <span class="event"> | |
574 <xsl:apply-templates mode="text"/> | |
575 </span> | |
576 </xsl:template> | |
577 | |
578 <!-- MML --> | |
579 <xsl:template match="mml:*" mode="text"> | |
580 <xsl:copy-of select="."/> | |
581 </xsl:template> | |
582 | |
583 <!-- XHTML: remove the xhtml namespace --> | |
584 <xsl:template match="xhtml:*" mode="text"> | |
585 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/> | |
586 <xsl:variable name="isTable" select="name() = 'table'"/> | |
587 <xsl:choose> | |
588 <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)"> | |
589 <xsl:element name="{name()}" namespace=""> | |
590 <xsl:copy-of select="@*"/> | |
591 <xsl:apply-templates mode="text"/> | |
592 </xsl:element> | |
593 </xsl:when> | |
594 <xsl:otherwise></xsl:otherwise> | |
595 </xsl:choose> | |
596 </xsl:template> | |
597 | |
598 <xsl:template match="figure" mode="text"> | |
599 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/> | |
600 <xsl:choose> | |
601 <xsl:when test="not($hasLabel)"> | |
602 <xsl:variable name="figureFileName"> | |
603 <xsl:choose> | |
604 <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="replace(./@xlink:href, '/', '.')"/></xsl:when> | |
605 <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="./image/@file"/></xsl:when> | |
606 <xsl:otherwise><xsl:value-of select="./image/@file"/></xsl:otherwise> | |
607 </xsl:choose> | |
608 </xsl:variable> | |
609 <xsl:variable name="figureNumber"> | |
610 <xsl:choose> | |
611 <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when> | |
612 <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:when> | |
613 <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:otherwise> | |
614 </xsl:choose> | |
615 </xsl:variable> | |
616 <xsl:variable name="figureCaption" select="./caption/text()"/> | |
617 <xsl:variable name="figureDescription" select="./description/text()"/> | |
618 <xsl:variable name="figureVariables" select="./variables/text()"/> | |
619 <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float none')"/> | |
620 </xsl:when> | |
621 <xsl:otherwise></xsl:otherwise> | |
622 </xsl:choose> | |
623 </xsl:template> | |
624 | |
625 <xsl:template match="handwritten" mode="text"> | |
626 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/> | |
627 <xsl:choose> | |
628 <xsl:when test="not($hasLabel)"> | |
629 <xsl:variable name="fileName" select="@file"/> | |
630 <xsl:variable name="href" select="@xlink:href"/> | |
631 <xsl:sequence select="mpdl:showHandwritten($fileName, $href)"/> | |
632 </xsl:when> | |
633 <xsl:otherwise></xsl:otherwise> | |
634 </xsl:choose> | |
635 </xsl:template> | |
636 | |
637 | |
638 <!-- textPollux links --> | |
639 <xsl:template match="w" mode="text"> | |
640 <xsl:variable name="baseUrlLex" select="'http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/'"/> | |
641 <xsl:variable name="wordLanguage" select="@lang"/> | |
642 <xsl:variable name="form" select="@form"/> | |
643 <a class="textPollux"> | |
644 <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&word=', $form, '&output=html')"/></xsl:attribute> | |
645 <xsl:apply-templates mode="text"/> | |
646 </a> | |
647 </xsl:template> | |
648 | |
649 <xsl:template match="s" mode="text"> | |
650 <xsl:variable name="actualSN"> | |
651 <xsl:choose> | |
652 <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> | |
653 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> | |
654 </xsl:choose> | |
655 </xsl:variable> | |
656 <a name="sn{$actualSN}"></a> | |
657 <xsl:choose> | |
658 <!-- Show the sentence in color light grey if it is given as sn --> | |
659 <xsl:when test="$sn >= 0 and $sn = $actualSN"> | |
660 <span class="s highlight"> | |
661 <xsl:if test="contains($options, 'withXmlNodeId')"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if> | |
662 <xsl:apply-templates mode="text"/> | |
663 </span> | |
664 </xsl:when> | |
665 <xsl:otherwise> | |
666 <span class="s"> | |
667 <xsl:if test="contains($options, 'withXmlNodeId')"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if> | |
668 <xsl:apply-templates mode="text"/> | |
669 </span> | |
670 </xsl:otherwise> | |
671 </xsl:choose> | |
672 </xsl:template> | |
673 | |
674 | |
675 <xsl:template match="text()" mode="text"> | |
676 <xsl:variable name="parentS" select="./ancestor::s"/> | |
677 <xsl:variable name="actualSN"> | |
678 <xsl:choose> | |
679 <xsl:when test="$parentS = $firstSentence and ($topPB >> $parentS)">0</xsl:when> | |
680 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> | |
681 </xsl:choose> | |
682 </xsl:variable> | |
683 <xsl:choose> | |
684 <xsl:when test="$highlightQuery != '' and $sn >= 0 and $sn = $actualSN"> | |
685 <xsl:sequence select="text:highlight(string(.), $highlightQueryTerms, $highlightQueryWords, 'false')"/> | |
686 </xsl:when> | |
687 <xsl:otherwise> | |
688 <xsl:value-of select="."/> | |
689 </xsl:otherwise> | |
690 </xsl:choose> | |
691 </xsl:template> | |
692 | |
693 </xsl:stylesheet> |