Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / slides / teihtml-slides.xsl @ 187

History | View | Annotate | Download (18.5 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" 
3
		xmlns:atom="http://www.w3.org/2005/Atom"
4
                xmlns:rng="http://relaxng.org/ns/structure/1.0"
5
                xmlns:teix="http://www.tei-c.org/ns/Examples"                
6
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7
                xmlns:tei="http://www.tei-c.org/ns/1.0"
8
                xmlns:xlink="http://www.w3.org/1999/xlink"
9
                xmlns:m="http://www.w3.org/1998/Math/MathML"
10
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
11
                exclude-result-prefixes="tei xlink xhtml m"
12
                version="2.0">
13
  <xsl:import href="../xhtml2/tei.xsl"/>
14

    
15
  <xsl:strip-space elements="teix:* rng:* xsl:* xhtml:* atom:* m:*"/>
16
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
17
      <desc>
18
         <p>
19
      TEI stylesheet for making HTML presentations from TEI documents
20
      </p>
21
         <p>This software is dual-licensed:
22

    
23
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
24
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
25

    
26
2. http://www.opensource.org/licenses/BSD-2-Clause
27
		
28
All rights reserved.
29

    
30
Redistribution and use in source and binary forms, with or without
31
modification, are permitted provided that the following conditions are
32
met:
33

    
34
* Redistributions of source code must retain the above copyright
35
notice, this list of conditions and the following disclaimer.
36

    
37
* Redistributions in binary form must reproduce the above copyright
38
notice, this list of conditions and the following disclaimer in the
39
documentation and/or other materials provided with the distribution.
40

    
41
This software is provided by the copyright holders and contributors
42
"as is" and any express or implied warranties, including, but not
43
limited to, the implied warranties of merchantability and fitness for
44
a particular purpose are disclaimed. In no event shall the copyright
45
holder or contributors be liable for any direct, indirect, incidental,
46
special, exemplary, or consequential damages (including, but not
47
limited to, procurement of substitute goods or services; loss of use,
48
data, or profits; or business interruption) however caused and on any
49
theory of liability, whether in contract, strict liability, or tort
50
(including negligence or otherwise) arising in any way out of the use
51
of this software, even if advised of the possibility of such damage.
52
</p>
53
         <p>Author: See AUTHORS</p>
54
         <p>Id: $Id: teihtml-slides.xsl 9669 2011-11-07 19:17:54Z rahtz $</p>
55
         <p>Copyright: 2011, TEI Consortium</p>
56
      </desc>
57
   </doc>
58
  <xsl:output encoding="utf-8" method="xml" doctype-public="-//W3C//DTD XHTML 1.1//EN"/>
59
  <xsl:param name="outputEncoding">utf-8</xsl:param>
60
  <xsl:param name="outputMethod">xml</xsl:param>
61
  <xsl:param name="outputSuffix">.xhtml</xsl:param>
62
  <xsl:param name="doctypePublic">-//W3C//DTD XHTML 1.1//EN</xsl:param>
63
  <xsl:param name="doctypeSystem">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</xsl:param>
64
  <xsl:param name="cssFile">http://www.tei-c.org/stylesheet/teislides.css</xsl:param>
65
  <xsl:param name="logoFile">logo.png</xsl:param>
66
  <xsl:param name="logoWidth">60</xsl:param>
67
  <xsl:param name="logoHeight">60</xsl:param>
68
  <xsl:param name="spaceCharacter">&#160;</xsl:param>
69
  <xsl:template name="lineBreak">
70
      <xsl:param name="id"/>
71
      <xhtml:br/>
72
  </xsl:template>
73
   <!--
74
<xsl:text>(</xsl:text>
75
<xsl:value-of select="$id"/>
76
<xsl:text>)</xsl:text>
77
-->
78
  <xsl:param name="numberHeadings"/>
79
  <xsl:param name="splitLevel">0</xsl:param>
80
  <xsl:param name="STDOUT">false</xsl:param>
81
  <xsl:param name="subTocDepth">-1</xsl:param>
82
  <xsl:param name="topNavigationPanel"/>
83
  <xsl:param name="bottomNavigationPanel">true</xsl:param>
84
  <xsl:param name="linkPanel"/>
85
  <xsl:template name="copyrightStatement"/>
86
  <xsl:param name="makingSlides">true</xsl:param>
87

    
88
  <xsl:template match="tei:div" mode="number">
89
      <xsl:number level="any"/>
90
  </xsl:template>
91

    
92

    
93
  <xsl:template name="locateParentDiv">
94
    <xsl:choose>
95
      <xsl:when test="ancestor-or-self::tei:div">
96
	<xsl:apply-templates mode="genid" select="ancestor::tei:div[last()]"/>
97
      </xsl:when>
98
      <xsl:when test="ancestor-or-self::tei:div1">
99
	<xsl:apply-templates mode="genid" select="ancestor::tei:div1"/>
100
      </xsl:when>
101
    </xsl:choose>
102
  </xsl:template>
103

    
104
  <xsl:template match="tei:*" mode="genid">
105
    <xsl:value-of select="$masterFile"/>
106
    <xsl:apply-templates select="ancestor-or-self::tei:div1|ancestor-or-self::tei:div[1]" mode="number"/>
107
  </xsl:template>
108

    
109
  <xsl:template match="tei:docAuthor">
110
      <div class="docAuthor">
111
         <xsl:apply-templates/>
112
      </div>
113
  </xsl:template>
114

    
115
  <xsl:template match="tei:docDate">
116
      <div class="docDate">
117
         <xsl:apply-templates/>
118
      </div>
119
  </xsl:template>
120

    
121
  <xsl:template match="/tei:TEI">
122
      <xsl:param name="slidenum">
123
         <xsl:value-of select="$masterFile"/>0</xsl:param>
124

    
125
      <xsl:variable name="outName">
126
         <xsl:call-template name="outputChunkName">
127
	           <xsl:with-param name="ident">
128
	              <xsl:value-of select="$slidenum"/>
129
	           </xsl:with-param>
130
         </xsl:call-template>
131
      </xsl:variable>
132

    
133
      <xsl:if test="$verbose='true'">
134
         <xsl:message>Opening file <xsl:value-of select="$outName"/>
135
         </xsl:message>
136
      </xsl:if>
137
      <xsl:result-document doctype-public="{$doctypePublic}" doctype-system="{$doctypeSystem}"
138
                           encoding="{$outputEncoding}"
139
                           href="{$outName}"
140
                           method="{$outputMethod}">
141
         <xsl:call-template name="mainslide"/>
142
      </xsl:result-document>
143
      <xsl:if test="$verbose='true'">
144
         <xsl:message>Closing file <xsl:value-of select="$outName"/>
145
         </xsl:message>
146
      </xsl:if>
147

    
148
      <xsl:for-each select="tei:text/tei:body">
149
         <xsl:apply-templates select="tei:div|tei:div1"/>
150
      </xsl:for-each>
151
  </xsl:template>
152

    
153
  <xsl:template name="xrefpanel">
154
      <xsl:param name="homepage"/>
155
      <xsl:param name="mode"/>
156
      <xsl:variable name="first">
157
         <xsl:value-of select="$masterFile"/>0</xsl:variable>
158
      <xsl:variable name="prev">
159
         <xsl:choose>
160
            <xsl:when test="preceding-sibling::tei:div">
161
               <xsl:apply-templates select="preceding-sibling::tei:div[1]" mode="genid"/>
162
            </xsl:when>
163
            <xsl:when test="preceding::tei:div">
164
               <xsl:apply-templates select="preceding::tei:div[1]" mode="genid"/>
165
            </xsl:when>
166
            <xsl:when test="preceding::tei:div1">
167
               <xsl:apply-templates select="preceding::tei:div1[1]" mode="genid"/>
168
            </xsl:when>
169
         </xsl:choose>
170
      </xsl:variable>
171
      <xsl:if test="not($prev='')">
172
         <a class="xreflink" accesskey="p" href="{concat($prev,$outputSuffix)}">
173
            <span class="button">«</span>
174
         </a>
175
      </xsl:if>
176
      <xsl:text>  </xsl:text>
177
      <a class="xreflink" accesskey="f" href="{concat($first,$outputSuffix)}">
178
         <span class="button">^</span>
179
      </a>
180
      <xsl:variable name="next">
181
         <xsl:choose>
182
            <xsl:when test="tei:div">
183
               <xsl:apply-templates select="tei:div[1]" mode="genid"/>
184
	           </xsl:when>
185
            <xsl:when test="following-sibling::tei:div">
186
               <xsl:apply-templates select="following-sibling::tei:div[1]" mode="genid"/>
187
            </xsl:when>
188
            <xsl:when test="following::tei:div">
189
               <xsl:apply-templates select="following::tei:div[1]" mode="genid"/>
190
            </xsl:when>
191
            <xsl:when test="following::tei:div1">
192
               <xsl:apply-templates select="following::tei:div1[1]" mode="genid"/>
193
            </xsl:when>
194
         </xsl:choose>
195
      </xsl:variable>
196
      <xsl:if test="not($next='')">
197
         <a class="xreflink" accesskey="n" href="{concat($next,$outputSuffix)}">
198
            <span class="button">»</span>
199
         </a>
200
      </xsl:if>
201
      <xsl:text> </xsl:text>
202
      <xsl:apply-templates select="." mode="number"/>
203
  </xsl:template>
204

    
205
  <xsl:template name="mainslide">
206
      <html>
207
         <xsl:call-template name="addLangAtt"/>
208
         <head>
209
            <title>
210
               <xsl:call-template name="generateTitle"/>
211
            </title>
212
            <xsl:call-template name="includeCSS"/>
213
            <xsl:call-template name="cssHook"/>
214
            <xsl:call-template name="javascriptHook"/>
215
         </head>
216
         <body>
217
            <div class="slidetitle" style="font-size: 36pt;">
218
               <xsl:call-template name="generateTitle"/>
219
            </div>
220
            <div class="slidemain">
221
               <xsl:apply-templates select="tei:text/tei:front//tei:docAuthor"/>
222
               <xsl:apply-templates select="tei:text/tei:front//tei:docDate"/>
223
               <ul class="slidetoc">
224
                  <xsl:for-each select="tei:text/tei:body">
225
                     <xsl:for-each select="tei:div|tei:div1">
226
                        <xsl:variable name="n">
227
                           <xsl:apply-templates select="." mode="genid"/>
228
                        </xsl:variable>
229
                        <li class="slidetoc">
230
                           <a href="{$n}.xhtml">
231
                              <xsl:value-of select="tei:head"/>
232
                           </a>
233
                        </li>
234
                     </xsl:for-each>
235
                  </xsl:for-each>
236
               </ul>
237
            </div>
238
            <div class="slidebottom">
239
	              <div class="slidebottom-image">
240
	                 <img id="logo" src="{$logoFile}" width="{$logoWidth}" height="{$logoHeight}"
241
                       alt="logo"/>
242
	              </div>
243
	              <div class="slidebottom-text">
244
	                 <xsl:variable name="next">
245
	                    <xsl:value-of select="$masterFile"/>
246
	                    <xsl:text>1</xsl:text>
247
	                 </xsl:variable>
248
	                 <a accesskey="n" href="{concat($next,$outputSuffix)}">Start</a>
249
	              </div>
250
            </div>
251
         </body>
252
      </html>
253
  </xsl:template>
254

    
255
   <xsl:template name="includeJavascript">
256
      <xsl:variable name="prev">
257
         <xsl:choose>	
258
            <xsl:when test="preceding-sibling::tei:div">
259
	              <xsl:apply-templates select="preceding-sibling::tei:div[1]" mode="genid"/>
260
            </xsl:when>
261
            <xsl:when test="preceding::tei:div1">
262
	              <xsl:apply-templates select="preceding::tei:div1[1]" mode="genid"/>
263
            </xsl:when>
264
            <xsl:when test="preceding::tei:div">
265
	              <xsl:apply-templates select="preceding::tei:div[1]" mode="genid"/>
266
            </xsl:when>
267
            <xsl:otherwise>
268
	              <xsl:value-of select="$masterFile"/>
269
	              <xsl:text>0</xsl:text>
270
            </xsl:otherwise>
271
         </xsl:choose>
272
      </xsl:variable>
273
      <xsl:variable name="next">
274
         <xsl:choose>
275
            <xsl:when test="tei:div">
276
               <xsl:apply-templates select="tei:div[1]" mode="genid"/>
277
	           </xsl:when>
278

    
279
            <xsl:when test="following-sibling::tei:div">
280
	              <xsl:apply-templates select="following-sibling::tei:div[1]" mode="genid"/>
281
            </xsl:when>
282
            <xsl:when test="following::tei:div1">
283
	              <xsl:apply-templates select="following::tei:div1[1]" mode="genid"/>
284
            </xsl:when>
285
            <xsl:when test="following::tei:div">
286
	              <xsl:apply-templates select="following::tei:div[1]" mode="genid"/>
287
            </xsl:when>
288
            <xsl:otherwise>
289
	              <xsl:value-of select="$masterFile"/>
290
	              <xsl:text>0</xsl:text>
291
            </xsl:otherwise>
292
         </xsl:choose>
293
      </xsl:variable>
294
      <xsl:call-template name="writeJavascript">
295
         <xsl:with-param name="content">
296
            <xsl:text>
297
    var isOp = navigator.userAgent.indexOf('Opera') &gt; -1 ? 1 : 0;
298
    function keys(key) {
299
    if (!key) {
300
    key = event;
301
    key.which = key.keyCode;
302
    }
303
    switch (key.which) {
304
    case 10: // return
305
    case 32: // spacebar
306
    case 34: // page down
307
    case 39: // rightkey
308
    // case 40: 
309
    // downkey
310
    document.location = "</xsl:text>
311
            <xsl:value-of select="$next"/>
312
            <xsl:text>.xhtml";
313
    break;
314
    case 33: // page up
315
    case 37: // leftkey
316
    //case 38: 
317
    // upkey
318
    document.location = "</xsl:text>
319
            <xsl:value-of select="$prev"/>
320
            <xsl:text>.xhtml";
321
    break;
322
	}
323
	}
324
	function startup() {      
325
	if (!isOp) {		
326
	document.onkeyup = keys;
327
	document.onclick = clicker;
328
	}
329
	}
330
	
331
	function clicker(e) {
332
	var target;
333
	if (window.event) {
334
	target = window.event.srcElement;
335
	e = window.event;
336
	} else target = e.target;
337
	if (target.href != null ) return true;
338
	if (!e.which || e.which == 1) 
339
	document.location = "</xsl:text>
340
	           <xsl:value-of select="$next"/>
341
	           <xsl:text>.xhtml";
342
	}
343
	
344
	window.onload = startup;
345
  </xsl:text>
346
         </xsl:with-param>
347
      </xsl:call-template>
348
   </xsl:template>
349

    
350
  <xsl:template match="tei:body/tei:div[tei:div]">
351
      <xsl:variable name="slidenum">
352
         <xsl:value-of select="$masterFile"/>
353
         <xsl:number/>
354
      </xsl:variable>
355
      <xsl:variable name="outName">
356
         <xsl:call-template name="outputChunkName">
357
	           <xsl:with-param name="ident">
358
	              <xsl:value-of select="$slidenum"/>
359
	           </xsl:with-param>
360
         </xsl:call-template>
361
      </xsl:variable>
362

    
363
      <xsl:if test="$verbose='true'">
364
         <xsl:message>Opening file <xsl:value-of select="$outName"/>
365
         </xsl:message>
366
      </xsl:if>
367
      <xsl:result-document doctype-public="{$doctypePublic}" doctype-system="{$doctypeSystem}"
368
                           encoding="{$outputEncoding}"
369
                           href="{$outName}"
370
                           method="{$outputMethod}">
371
        <html>
372
            <xsl:call-template name="addLangAtt"/>
373
            <head>
374
               <title>
375
                  <xsl:value-of select="tei:head"/>
376
               </title>
377
               <xsl:call-template name="includeCSS"/>
378
               <xsl:call-template name="cssHook"/>
379
               <xsl:call-template name="includeJavascript"/>
380
               <xsl:call-template name="javascriptHook"/>
381
            </head>
382
            <body>
383
               <h1>
384
                  <xsl:value-of select="tei:head"/>
385
               </h1>
386
            </body>
387
        </html>
388
      </xsl:result-document>
389
      <xsl:if test="$verbose='true'">
390
         <xsl:message>Closing file <xsl:value-of select="$outName"/>
391
         </xsl:message>
392
      </xsl:if>
393

    
394
      <xsl:apply-templates select="tei:div"/>
395
  </xsl:template>
396

    
397

    
398
  <xsl:template match="tei:body/tei:div|tei:div">
399
      <xsl:choose>
400
         <xsl:when test="$splitLevel&gt;-1">
401
	           <xsl:variable name="slidenum">
402
	              <xsl:apply-templates select="." mode="genid"/>
403
	           </xsl:variable>
404
	
405
	           <xsl:variable name="outName">
406
	              <xsl:call-template name="outputChunkName">
407
	                 <xsl:with-param name="ident">
408
	                    <xsl:value-of select="$slidenum"/>
409
	                 </xsl:with-param>
410
	              </xsl:call-template>
411
	           </xsl:variable>
412
	
413
	           <xsl:if test="$verbose='true'">
414
	              <xsl:message>Opening file <xsl:value-of select="$outName"/>
415
               </xsl:message>
416
	           </xsl:if>
417
	           <xsl:result-document doctype-public="{$doctypePublic}" doctype-system="{$doctypeSystem}"
418
                                 encoding="{$outputEncoding}"
419
                                 href="{$outName}"
420
                                 method="{$outputMethod}">
421
	              <xsl:call-template name="slideout"/>
422
	           </xsl:result-document>
423
	           <xsl:if test="$verbose='true'">
424
	              <xsl:message>Closing file <xsl:value-of select="$outName"/>
425
               </xsl:message>
426
	           </xsl:if>
427
         </xsl:when>
428
         <xsl:otherwise>
429
	           <xsl:call-template name="slidebody"/>
430
         </xsl:otherwise>
431
      </xsl:choose>
432
  </xsl:template>
433

    
434

    
435
  <xsl:template name="slideout">
436
      <html>
437
         <xsl:call-template name="addLangAtt"/>
438
         <head>
439
            <title>
440
               <xsl:value-of select="tei:head"/>
441
            </title>
442
            <xsl:call-template name="includeCSS"/>
443
            <xsl:call-template name="cssHook"/>
444
            <xsl:call-template name="includeJavascript"/>
445
            <xsl:call-template name="javascriptHook"/>
446
         </head>
447
         <body>
448
            <xsl:call-template name="slidebody"/>
449
         </body>
450
      </html>
451
  </xsl:template>
452

    
453
  <xsl:template name="slidebody">
454
      <div class="slidetop">
455
         <div class="slidetitle">
456
            <xsl:call-template name="header">
457
	              <xsl:with-param name="display">full</xsl:with-param>
458
	           </xsl:call-template>
459
         </div>
460
         <xsl:if test="$splitLevel &gt;-1">
461
            <div class="xref">
462
               <xsl:call-template name="xrefpanel"/>
463
            </div>
464
         </xsl:if>
465
      </div>
466
      <div class="slidemain">
467
         <xsl:apply-templates/>
468
      </div>
469
      <div class="slidebottom">
470
         <xsl:call-template name="slideBottom"/>
471
      </div>
472
  </xsl:template>
473

    
474

    
475
  <xsl:template name="slideBottom">
476
      <div class="slidebottom">
477
         <div class="slidebottom-image">
478
	           <img id="logo" src="{$logoFile}" width="{$logoWidth}" height="${logoHeight}"
479
                 alt="logo"/>
480
         </div>
481
         <div class="slidebottom-text">
482
	           <xsl:call-template name="generateTitle"/>
483
         </div>
484
      </div>
485
  </xsl:template>
486

    
487
  <xsl:template match="tei:row">
488
	     <xsl:variable name="c">
489
	        <xsl:number/>
490
	     </xsl:variable>
491
	     <xsl:variable name="class">
492
	        <xsl:choose>
493
	           <xsl:when test="@role">
494
		             <xsl:value-of select="@role"/>
495
	           </xsl:when>
496
	           <xsl:when test="$c mod 2=0">
497
	              <xsl:text>Even</xsl:text>
498
	           </xsl:when>
499
	           <xsl:otherwise>
500
	              <xsl:text>Odd</xsl:text>
501
	           </xsl:otherwise>
502
	        </xsl:choose>
503
	     </xsl:variable>
504
	     <tr class="{$class}">
505
	        <xsl:apply-templates/>
506
	     </tr>
507
  </xsl:template>
508

    
509
  <xsl:template match="teix:egXML">
510
      <xsl:param name="simple">false</xsl:param>
511
      <xsl:param name="highlight"/>
512
    
513
      <div class="pre">
514
	        <xsl:apply-templates mode="verbatim">
515
	           <xsl:with-param name="highlight">
516
	              <xsl:value-of select="$highlight"/>
517
	           </xsl:with-param>
518
	        </xsl:apply-templates>
519
      </div>
520
  </xsl:template>
521

    
522
  <xsl:template match="xhtml:*">
523
      <xsl:copy-of select="."/>
524
  </xsl:template>
525

    
526
  <xsl:template match="tei:att">
527
      <span class="att">
528
         <xsl:apply-templates/>
529
      </span>
530
  </xsl:template>
531

    
532
</xsl:stylesheet>