root / tmp / org.txm.oriflamms.rcp / res / 1-default-html.xsl @ 3119
Historique | Voir | Annoter | Télécharger (16,12 ko)
1 |
<?xml version="1.0"?> |
---|---|
2 |
<xsl:stylesheet |
3 |
xmlns:edate="http://exslt.org/dates-and-times" |
4 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
5 |
xmlns:tei="http://www.tei-c.org/ns/1.0" |
6 |
xmlns:txm="http://textometrie.org/1.0" |
7 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" |
8 |
exclude-result-prefixes="#all" version="2.0"> |
9 |
|
10 |
<xsl:output method="xml" encoding="UTF-8" |
11 |
omit-xml-declaration="no" indent="no" /> |
12 |
|
13 |
<!-- <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="no" |
14 |
indent="no" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> --> |
15 |
|
16 |
|
17 |
<xsl:strip-space elements="*" /> |
18 |
|
19 |
<xsl:param name="pagination-element"> |
20 |
pb |
21 |
</xsl:param> |
22 |
|
23 |
<xsl:variable name="word-element"> |
24 |
<xsl:choose> |
25 |
<xsl:when test="//tei:c//txm:form"> |
26 |
c |
27 |
</xsl:when> |
28 |
<xsl:otherwise> |
29 |
w |
30 |
</xsl:otherwise> |
31 |
</xsl:choose> |
32 |
</xsl:variable> |
33 |
|
34 |
<xsl:variable name="page-number-adjust" as="xs:integer"> |
35 |
<xsl:choose> |
36 |
<xsl:when test="//tei:c//txm:form"> |
37 |
1 |
38 |
</xsl:when> |
39 |
<xsl:otherwise> |
40 |
2 |
41 |
</xsl:otherwise> |
42 |
</xsl:choose> |
43 |
</xsl:variable> |
44 |
|
45 |
|
46 |
<xsl:variable name="inputtype"> |
47 |
<xsl:choose> |
48 |
<xsl:when test="//tei:w//txm:form"> |
49 |
xmltxm |
50 |
</xsl:when> |
51 |
<xsl:otherwise> |
52 |
xmlw |
53 |
</xsl:otherwise> |
54 |
</xsl:choose> |
55 |
</xsl:variable> |
56 |
|
57 |
<xsl:variable name="filename"> |
58 |
<xsl:analyze-string select="document-uri(.)" |
59 |
regex="^(.*)/([^/]+)\.[^/]+$"> |
60 |
<xsl:matching-substring> |
61 |
<xsl:value-of select="regex-group(2)" /> |
62 |
</xsl:matching-substring> |
63 |
</xsl:analyze-string> |
64 |
</xsl:variable> |
65 |
|
66 |
<xsl:template match="/"> |
67 |
<html> |
68 |
<head> |
69 |
<title> |
70 |
<xsl:choose> |
71 |
<xsl:when test="//tei:text/@id"> |
72 |
<xsl:value-of select="//tei:text[1]/@id" /> |
73 |
</xsl:when> |
74 |
<xsl:otherwise> |
75 |
<xsl:value-of select="$filename" /> |
76 |
</xsl:otherwise> |
77 |
</xsl:choose> |
78 |
</title> |
79 |
<meta http-equiv="Content-Type" |
80 |
content="text/html;charset=UTF-8" /> |
81 |
<link rel="stylesheet" media="all" type="text/css" |
82 |
href="css/bvhepistemon2014.css" /> |
83 |
<!-- <title> <xsl:if test="$author[not(contains(.,'anonym'))]"> <xsl:value-of |
84 |
select="$author"/><xsl:text> : </xsl:text> </xsl:if> <xsl:value-of select="$title-normal"/> |
85 |
</title> --> |
86 |
</head> |
87 |
<xsl:apply-templates |
88 |
select="descendant::tei:text" /> |
89 |
</html> |
90 |
</xsl:template> |
91 |
|
92 |
<xsl:template match="tei:text"> |
93 |
<body> |
94 |
<xsl:if test="$word-element='w'"> |
95 |
<a class="txm-page" title="1" next-word-id="w_0" /> |
96 |
<div class="metadata-page"> |
97 |
<h1> |
98 |
<xsl:value-of select="@id"></xsl:value-of> |
99 |
</h1> |
100 |
<br /> |
101 |
<table> |
102 |
<xsl:for-each select="@*"> |
103 |
<tr> |
104 |
<td> |
105 |
<xsl:value-of select="name()" /> |
106 |
</td> |
107 |
<td> |
108 |
<xsl:value-of select="." /> |
109 |
</td> |
110 |
</tr> |
111 |
</xsl:for-each> |
112 |
</table> |
113 |
</div> |
114 |
|
115 |
</xsl:if> |
116 |
<xsl:apply-templates /> |
117 |
</body> |
118 |
</xsl:template> |
119 |
|
120 |
<xsl:template match="*"> |
121 |
<xsl:choose> |
122 |
<xsl:when test="descendant::tei:p|descendant::tei:ab"> |
123 |
<div> |
124 |
<xsl:call-template name="addClass" /> |
125 |
<xsl:apply-templates /> |
126 |
</div> |
127 |
<xsl:text>
</xsl:text> |
128 |
</xsl:when> |
129 |
<xsl:otherwise> |
130 |
<span> |
131 |
<xsl:call-template name="addClass" /> |
132 |
<xsl:if test="self::tei:add[@del]"> |
133 |
<xsl:attribute name="title"><xsl:value-of |
134 |
select="@del" /></xsl:attribute> |
135 |
</xsl:if> |
136 |
<xsl:apply-templates /> |
137 |
</span> |
138 |
<xsl:call-template name="spacing" /> |
139 |
</xsl:otherwise> |
140 |
</xsl:choose> |
141 |
</xsl:template> |
142 |
|
143 |
<xsl:template |
144 |
match="@*|processing-instruction()|comment()"> |
145 |
<!--<xsl:copy/> --> |
146 |
</xsl:template> |
147 |
|
148 |
<!-- <xsl:template match="comment()"> <xsl:copy/> </xsl:template> --> |
149 |
<xsl:template match="text()"> |
150 |
<xsl:value-of select="normalize-space(.)" /> |
151 |
</xsl:template> |
152 |
|
153 |
<xsl:template name="addClass"> |
154 |
<xsl:attribute name="class"> |
155 |
<xsl:value-of select="local-name(.)" /> |
156 |
<xsl:if test="@type"><xsl:value-of |
157 |
select="concat('-',@type)" /></xsl:if> |
158 |
<xsl:if test="@subtype"><xsl:value-of |
159 |
select="concat('-',@subtype)" /></xsl:if> |
160 |
<xsl:if test="@rend"><xsl:value-of |
161 |
select="concat('-',@rend)" /></xsl:if> |
162 |
</xsl:attribute> |
163 |
</xsl:template> |
164 |
|
165 |
<xsl:template match="tei:p|tei:ab|tei:lg"> |
166 |
<p> |
167 |
<xsl:call-template name="addClass" /> |
168 |
<xsl:apply-templates /> |
169 |
</p> |
170 |
<xsl:text>
</xsl:text> |
171 |
</xsl:template> |
172 |
|
173 |
<xsl:template match="tei:head"> |
174 |
<h2> |
175 |
<xsl:call-template name="addClass" /> |
176 |
<xsl:apply-templates /> |
177 |
</h2> |
178 |
</xsl:template> |
179 |
|
180 |
<xsl:template match="//tei:lb"> |
181 |
<xsl:variable name="lbcount"> |
182 |
<xsl:choose> |
183 |
<xsl:when test="ancestor::tei:ab"> |
184 |
<xsl:number from="tei:ab" level="any" /> |
185 |
</xsl:when> |
186 |
<xsl:when test="ancestor::tei:p"> |
187 |
<xsl:number from="tei:p" level="any" /> |
188 |
</xsl:when> |
189 |
<xsl:otherwise> |
190 |
999 |
191 |
</xsl:otherwise> |
192 |
</xsl:choose> |
193 |
</xsl:variable> |
194 |
<xsl:if test="@rend='hyphen(-)'"> |
195 |
<span class="hyphen">-</span> |
196 |
</xsl:if> |
197 |
<xsl:if test="@rend='hyphen(=)'"> |
198 |
<span class="hyphen">=</span> |
199 |
</xsl:if> |
200 |
<xsl:if |
201 |
test="not($lbcount=1) or preceding-sibling::node()[matches(.,'\S')]"> |
202 |
<br /> |
203 |
<xsl:text>
</xsl:text> |
204 |
</xsl:if> |
205 |
<!-- <xsl:if test="@n and not(@rend='prose')"> <xsl:choose> <xsl:when test="matches(@n,'^[0-9]*[05]$')"> |
206 |
<!-\-<a title="{@n}" class="verseline" style="position:relative"> </a>-\-> |
207 |
<span class="verseline"><span class="verselinenumber"><xsl:value-of select="@n"/></span></span> |
208 |
</xsl:when> <xsl:when test="matches(@n,'[^0-9]')"> <!-\-<a title="{@n}" class="verseline" |
209 |
style="position:relative"> </a>-\-> <span class="verseline"><span class="verselinenumber"><xsl:value-of |
210 |
select="@n"/></span></span> </xsl:when> <xsl:otherwise> </xsl:otherwise> |
211 |
</xsl:choose> </xsl:if> --> |
212 |
<xsl:if test="@n"> |
213 |
<span class="verseline"> |
214 |
<span class="verselinenumber"> |
215 |
<xsl:value-of select="@n" /> |
216 |
</span> |
217 |
</span> |
218 |
</xsl:if> |
219 |
</xsl:template> |
220 |
|
221 |
<!-- Page breaks --> |
222 |
<xsl:template |
223 |
match="//*[local-name()=$pagination-element]"> |
224 |
|
225 |
<xsl:variable name="next-word-position" as="xs:integer"> |
226 |
<xsl:choose> |
227 |
<xsl:when test="following::*[local-name()=$word-element]"> |
228 |
<xsl:value-of |
229 |
select="count(following::*[local-name()=$word-element][1]/preceding::*[local-name()=$word-element])" /> |
230 |
</xsl:when> |
231 |
<xsl:otherwise> |
232 |
0 |
233 |
</xsl:otherwise> |
234 |
</xsl:choose> |
235 |
</xsl:variable> |
236 |
<xsl:variable name="next-pb-position" as="xs:integer"> |
237 |
<xsl:choose> |
238 |
<xsl:when |
239 |
test="following::*[local-name()=$pagination-element]"> |
240 |
<xsl:value-of |
241 |
select="count(following::*[local-name()=$pagination-element][1]/preceding::*[local-name()=$word-element])" /> |
242 |
</xsl:when> |
243 |
<xsl:otherwise> |
244 |
999999999 |
245 |
</xsl:otherwise> |
246 |
</xsl:choose> |
247 |
</xsl:variable> |
248 |
<xsl:variable name="next-word-id"> |
249 |
<xsl:choose> |
250 |
<xsl:when |
251 |
test="$next-pb-position - $next-word-position = 999999999"> |
252 |
w_0 |
253 |
</xsl:when> |
254 |
<xsl:when test="$next-pb-position > $next-word-position"> |
255 |
<xsl:value-of |
256 |
select="following::*[local-name()=$word-element][1]/@id" /> |
257 |
</xsl:when> |
258 |
<xsl:otherwise> |
259 |
w_0 |
260 |
</xsl:otherwise> |
261 |
</xsl:choose> |
262 |
</xsl:variable> |
263 |
|
264 |
|
265 |
<xsl:variable name="editionpagetype"> |
266 |
<xsl:choose> |
267 |
<xsl:when test="ancestor::tei:ab"> |
268 |
editionpageverse |
269 |
</xsl:when> |
270 |
<xsl:otherwise> |
271 |
editionpage |
272 |
</xsl:otherwise> |
273 |
</xsl:choose> |
274 |
</xsl:variable> |
275 |
<xsl:variable name="pagenumber"> |
276 |
<xsl:choose> |
277 |
<xsl:when test="@n"> |
278 |
<xsl:value-of select="@n" /> |
279 |
</xsl:when> |
280 |
<xsl:when test="@facs"> |
281 |
<xsl:value-of select="substring-before(@facs,'.')" /> |
282 |
</xsl:when> |
283 |
<xsl:otherwise> |
284 |
[NN] |
285 |
</xsl:otherwise> |
286 |
</xsl:choose> |
287 |
</xsl:variable> |
288 |
|
289 |
<xsl:variable name="page_id"> |
290 |
<xsl:value-of |
291 |
select="count(preceding::*[local-name()=$pagination-element])" /> |
292 |
</xsl:variable> |
293 |
|
294 |
<xsl:if |
295 |
test="//tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))][following::*[local-name()=$pagination-element][1][count(preceding::*[local-name()=$pagination-element]) = $page_id]]"> |
296 |
<xsl:text>
</xsl:text> |
297 |
<br /> |
298 |
<br /> |
299 |
<span |
300 |
style="display:block;border-top-style:solid;border-top-width:1px;border-top-color:gray;padding-top:5px"> |
301 |
<xsl:for-each |
302 |
select="//tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))][following::*[local-name()=$pagination-element][1][count(preceding::*[local-name()=$pagination-element]) = $page_id]]"> |
303 |
<xsl:variable name="note_count"> |
304 |
<xsl:value-of |
305 |
select="count(preceding::tei:note[not(@place='inline')]) + 1" /> |
306 |
</xsl:variable> |
307 |
<!--<p><xsl:value-of select="$note_count"/>. <a href="#noteref_{$note_count}" |
308 |
name="note_{$note_count}">[<xsl:value-of select="preceding::tei:cb[1]/@xml:id"/>, |
309 |
l. <xsl:value-of select="preceding::tei:lb[1]/@n"/>]</a><xsl:text> </xsl:text> |
310 |
<xsl:value-of select="."/></p> --> |
311 |
<span class="note"> |
312 |
<span style="position:absolute;left:-30px"> |
313 |
<a href="#noteref_{$note_count}" name="note_{$note_count}"> |
314 |
<xsl:value-of select="$note_count" /> |
315 |
</a> |
316 |
. |
317 |
</span> |
318 |
<xsl:apply-templates mode="#current" /> |
319 |
</span> |
320 |
</xsl:for-each> |
321 |
</span> |
322 |
<xsl:text>
</xsl:text> |
323 |
|
324 |
</xsl:if> |
325 |
|
326 |
<xsl:text>
</xsl:text> |
327 |
<br /> |
328 |
<xsl:text>
</xsl:text> |
329 |
<a class="txm-page" |
330 |
title="{count(preceding::*[local-name()=$pagination-element]) + $page-number-adjust}" |
331 |
next-word-id="{$next-word-id}" /> |
332 |
<span class="{$editionpagetype}"> |
333 |
- |
334 |
<xsl:value-of select="$pagenumber" /> |
335 |
- |
336 |
</span> |
337 |
<br /> |
338 |
<xsl:text>
</xsl:text> |
339 |
</xsl:template> |
340 |
|
341 |
<!-- Notes --> |
342 |
<xsl:template |
343 |
match="tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))]"> |
344 |
<!--<span style="color:violet"> [<b>Note :</b> <xsl:apply-templates/>] |
345 |
</span> --> |
346 |
<xsl:variable name="note_count"> |
347 |
<xsl:value-of |
348 |
select="count(preceding::tei:note[not(@place='inline') and not(matches(@type,'intern|auto'))]) + 1" /> |
349 |
</xsl:variable> |
350 |
<xsl:variable name="note_content"> |
351 |
<xsl:choose> |
352 |
<xsl:when test="descendant::txm:form"> |
353 |
<xsl:for-each select="descendant::txm:form"> |
354 |
<xsl:value-of select="." /> |
355 |
<xsl:if |
356 |
test="not(matches(following::txm:form[1],'^[.,\)]')) and not(matches(.,'^\S+[''’]$|^[‘\(]$'))"> |
357 |
<xsl:text> </xsl:text> |
358 |
</xsl:if> |
359 |
</xsl:for-each> |
360 |
</xsl:when> |
361 |
<xsl:otherwise> |
362 |
<xsl:value-of select="normalize-space(.)" /> |
363 |
</xsl:otherwise> |
364 |
</xsl:choose> |
365 |
</xsl:variable> |
366 |
<a title="{$note_content}" |
367 |
style="font-size:75%;position:relative;top:-5px" |
368 |
href="#note_{$note_count}" name="noteref_{$note_count}"> |
369 |
[ |
370 |
<xsl:value-of select="$note_count" /> |
371 |
] |
372 |
</a> |
373 |
<xsl:call-template name="spacing" /> |
374 |
</xsl:template> |
375 |
|
376 |
<xsl:template match="tei:note[@place='inline']"> |
377 |
<span class="noteinline"> |
378 |
<xsl:apply-templates /> |
379 |
</span> |
380 |
</xsl:template> |
381 |
|
382 |
<xsl:template match="//tei:w"> |
383 |
<span class="w"> |
384 |
<xsl:choose> |
385 |
<xsl:when test="descendant::tei:c//txm:form"> |
386 |
<xsl:apply-templates select="descendant::tei:c" /> |
387 |
</xsl:when> |
388 |
<xsl:otherwise> |
389 |
<xsl:if test="@id"> |
390 |
<xsl:attribute name="id"><xsl:value-of |
391 |
select="@id" /></xsl:attribute> |
392 |
</xsl:if> |
393 |
<xsl:attribute name="title"> |
394 |
<xsl:if test="@id"> |
395 |
<xsl:value-of select="@id"></xsl:value-of> |
396 |
</xsl:if> |
397 |
<xsl:if test="ancestor::tei:corr"> |
398 |
<xsl:value-of |
399 |
select="concat(' sic : ',@sic)" /> |
400 |
</xsl:if> |
401 |
<xsl:if test="ancestor::tei:reg"> |
402 |
<xsl:value-of |
403 |
select="concat(' orig : ',@orig)" /> |
404 |
</xsl:if> |
405 |
<xsl:choose> |
406 |
<xsl:when test="descendant::txm:ana"> |
407 |
<xsl:for-each |
408 |
select="descendant::txm:ana"> |
409 |
<xsl:value-of |
410 |
select="concat(' ',substring-after(@type,'#'),' : ',.)" /> |
411 |
</xsl:for-each> |
412 |
</xsl:when> |
413 |
<xsl:otherwise> |
414 |
<xsl:for-each |
415 |
select="@*[not(local-name()='id')]"> |
416 |
<xsl:value-of |
417 |
select="concat(' ',name(.),' : ',.)" /> |
418 |
</xsl:for-each> |
419 |
</xsl:otherwise> |
420 |
</xsl:choose> |
421 |
<xsl:if test="@*[matches(name(.),'pos$')]"> |
422 |
</xsl:if> |
423 |
</xsl:attribute> |
424 |
<xsl:choose> |
425 |
<xsl:when test="descendant::txm:form"> |
426 |
<xsl:apply-templates select="txm:form" /> |
427 |
</xsl:when> |
428 |
<xsl:otherwise> |
429 |
<xsl:apply-templates /> |
430 |
</xsl:otherwise> |
431 |
</xsl:choose> |
432 |
</xsl:otherwise> |
433 |
</xsl:choose> |
434 |
</span> |
435 |
<xsl:call-template name="spacing" /> |
436 |
</xsl:template> |
437 |
|
438 |
<!-- <xsl:template match="//txm:form"> <xsl:apply-templates/> </xsl:template> --> |
439 |
|
440 |
<xsl:template match="//tei:c[descendant::txm:form]"> |
441 |
<span class="c"> |
442 |
<xsl:if test="@id"> |
443 |
<xsl:attribute name="id"><xsl:value-of |
444 |
select="@id" /></xsl:attribute> |
445 |
</xsl:if> |
446 |
<xsl:attribute name="title"> |
447 |
<xsl:if test="@id"> |
448 |
<xsl:value-of select="@id"></xsl:value-of> |
449 |
</xsl:if> |
450 |
<xsl:choose> |
451 |
<xsl:when test="descendant::txm:ana"> |
452 |
<xsl:for-each select="descendant::txm:ana"> |
453 |
<xsl:if |
454 |
test="matches(@type,'expan|characters|letters-all|letters-alignable|abbr-n')"> |
455 |
<xsl:value-of |
456 |
select="concat(' ',substring-after(@type,'#'),' : ',.)" /> |
457 |
</xsl:if> |
458 |
</xsl:for-each> |
459 |
</xsl:when> |
460 |
<xsl:otherwise> |
461 |
<xsl:for-each select="@*[not(local-name()='id')]"> |
462 |
<xsl:value-of select="concat(' ',name(.),' : ',.)" /> |
463 |
</xsl:for-each> |
464 |
</xsl:otherwise> |
465 |
</xsl:choose> |
466 |
<xsl:if test="@*[matches(name(.),'pos$')]"> |
467 |
</xsl:if> |
468 |
</xsl:attribute> |
469 |
<xsl:choose> |
470 |
<xsl:when test="descendant::txm:form"> |
471 |
<xsl:apply-templates select="txm:form" /> |
472 |
</xsl:when> |
473 |
<xsl:otherwise> |
474 |
<xsl:apply-templates /> |
475 |
</xsl:otherwise> |
476 |
</xsl:choose> |
477 |
|
478 |
</span> |
479 |
</xsl:template> |
480 |
|
481 |
<xsl:template name="spacing"> |
482 |
<xsl:choose> |
483 |
<xsl:when test="$inputtype='xmltxm'"> |
484 |
<xsl:call-template name="spacing-xmltxm" /> |
485 |
</xsl:when> |
486 |
<xsl:otherwise> |
487 |
<xsl:call-template name="spacing-xmlw" /> |
488 |
</xsl:otherwise> |
489 |
</xsl:choose> |
490 |
</xsl:template> |
491 |
|
492 |
<xsl:template name="spacing-xmlw"> |
493 |
<xsl:choose> |
494 |
<xsl:when test="ancestor::tei:w" /> |
495 |
<xsl:when |
496 |
test="following::tei:w[1][matches(.,'^\s*[.,)\]]+\s*$')]" /> |
497 |
<xsl:when test="matches(.,'^\s*[(\[‘]+$|\w(''|’)\s*$')"></xsl:when> |
498 |
<xsl:when |
499 |
test="position()=last() and (ancestor::tei:choice or ancestor::tei:supplied[not(@rend='multi_s')])"></xsl:when> |
500 |
<xsl:when test="following-sibling::*[1][self::tei:note]"></xsl:when> |
501 |
<xsl:when |
502 |
test="following::tei:w[1][matches(.,'^\s*[:;!?]+\s*$')]"> |
503 |
<xsl:text> </xsl:text> |
504 |
</xsl:when> |
505 |
<xsl:otherwise> |
506 |
<xsl:text> </xsl:text> |
507 |
</xsl:otherwise> |
508 |
</xsl:choose> |
509 |
</xsl:template> |
510 |
|
511 |
<xsl:template name="spacing-xmltxm"> |
512 |
<xsl:choose> |
513 |
<xsl:when test="ancestor::tei:w" /> |
514 |
<xsl:when |
515 |
test="following::tei:w[1][matches(descendant::txm:form[1],'^[.,)\]]+$')]" /> |
516 |
<xsl:when |
517 |
test="matches(descendant::txm:form[1],'^[(\[‘]+$|\w(''|’)$')"></xsl:when> |
518 |
<xsl:when |
519 |
test="position()=last() and (ancestor::tei:choice or ancestor::tei:supplied[not(@rend='multi_s')])"></xsl:when> |
520 |
<xsl:when test="following-sibling::*[1][self::tei:note]"></xsl:when> |
521 |
<xsl:when |
522 |
test="following::tei:w[1][matches(descendant::txm:form[1],'^[:;!?]+$')]"> |
523 |
<xsl:text> </xsl:text> |
524 |
</xsl:when> |
525 |
<xsl:otherwise> |
526 |
<xsl:text> </xsl:text> |
527 |
</xsl:otherwise> |
528 |
</xsl:choose> |
529 |
</xsl:template> |
530 |
|
531 |
|
532 |
</xsl:stylesheet> |