]> git.stg.codes - stg.git/blob - doc/xslt/slides/html/tables.xsl
Fixed stupid bug in case conversion functions.
[stg.git] / doc / xslt / slides / html / tables.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 version="1.0">
4
5 <xsl:import href="slides-common.xsl"/>
6
7 <xsl:param name="blank.image" select="'blank.png'"/>
8 <xsl:param name="arrow.image" select="'pointer.png'"/>
9
10 <xsl:param name="toc.bg.color">#6A719C</xsl:param>
11 <xsl:param name="toc.width">220</xsl:param>
12
13 <xsl:param name="css.stylesheet" select="'slides-table.css'"/>
14
15 <!-- ============================================================ -->
16
17 <xsl:template name="foilgroup-body">
18   <table border="0" width="100%" summary="Navigation and body table"
19          cellpadding="0" cellspacing="0">
20     <tr>
21       <td width="{$toc.width}" valign="top" align="left">
22         <xsl:if test="$toc.bg.color != ''">
23           <xsl:attribute name="bgcolor">
24             <xsl:value-of select="$toc.bg.color"/>
25           </xsl:attribute>
26         </xsl:if>
27         <div class="ttoc">
28           <xsl:apply-templates select="." mode="t-toc"/>
29         </div>
30       </td>
31       <td>&#160;</td>
32       <td valign="top" align="left">
33         <xsl:if test="$body.bg.color != ''">
34           <xsl:attribute name="bgcolor">
35             <xsl:value-of select="$body.bg.color"/>
36           </xsl:attribute>
37         </xsl:if>
38         <div class="{name(.)}">
39           <xsl:apply-templates select="*[name(.) != 'foil'
40                                          and name(.) != 'foilgroup']"/>
41         </div>
42
43         <xsl:if test="$foilgroup.toc != 0">
44           <dl class="toc">
45             <xsl:apply-templates select="foil" mode="toc"/>
46           </dl>
47         </xsl:if>
48       </td>
49     </tr>
50   </table>
51 </xsl:template>
52
53 <xsl:template name="foil-body">
54   <table border="0" width="100%" summary="Navigation and body table"
55          cellpadding="0" cellspacing="0">
56     <tr>
57       <td width="{$toc.width}" valign="top" align="left">
58         <xsl:if test="$toc.bg.color != ''">
59           <xsl:attribute name="bgcolor">
60             <xsl:value-of select="$toc.bg.color"/>
61           </xsl:attribute>
62         </xsl:if>
63         <div class="ttoc">
64           <xsl:apply-templates select="." mode="t-toc"/>
65         </div>
66       </td>
67       <td>&#160;</td>
68       <td valign="top" align="left">
69         <xsl:if test="$body.bg.color != ''">
70           <xsl:attribute name="bgcolor">
71             <xsl:value-of select="$body.bg.color"/>
72           </xsl:attribute>
73         </xsl:if>
74         <div class="{name(.)}">
75           <xsl:apply-templates/>
76         </div>
77       </td>
78     </tr>
79   </table>
80 </xsl:template>
81
82 <!-- ============================================================ -->
83
84 <xsl:template match="foilgroup" mode="t-toc">
85   <xsl:variable name="thisfoilgroup" select="."/>
86
87   <xsl:for-each select="/slides/foil|/slides/foilgroup">
88     <xsl:choose>
89       <xsl:when test="name(.) = 'foilgroup'">
90         <xsl:choose>
91           <xsl:when test="$thisfoilgroup = .">
92             <img alt="+">
93               <xsl:attribute name="src">
94                 <xsl:call-template name="graphics-file">
95                   <xsl:with-param name="image" select="$arrow.image"/>
96                 </xsl:call-template>
97               </xsl:attribute>
98             </img>
99           </xsl:when>
100           <xsl:otherwise>
101             <img alt=" ">
102               <xsl:attribute name="src">
103                 <xsl:call-template name="graphics-file">
104                   <xsl:with-param name="image" select="$blank.image"/>
105                 </xsl:call-template>
106               </xsl:attribute>
107             </img>
108           </xsl:otherwise>
109         </xsl:choose>
110
111         <span class="ttoc-foilgroup">
112           <a>
113             <xsl:attribute name="href">
114               <xsl:apply-templates select="." mode="filename"/>
115             </xsl:attribute>
116             <xsl:apply-templates select="." mode="toc-title"/>
117           </a>
118         </span>
119         <br/>
120
121         <xsl:if test="$thisfoilgroup = .">
122           <xsl:for-each select="foil">
123             <img alt=" ">
124               <xsl:attribute name="src">
125                 <xsl:call-template name="graphics-file">
126                   <xsl:with-param name="image" select="$blank.image"/>
127                 </xsl:call-template>
128               </xsl:attribute>
129             </img>
130             <img alt=" ">
131               <xsl:attribute name="src">
132                 <xsl:call-template name="graphics-file">
133                   <xsl:with-param name="image" select="$blank.image"/>
134                 </xsl:call-template>
135               </xsl:attribute>
136             </img>
137
138             <span class="ttoc-foil">
139               <a>
140                 <xsl:attribute name="href">
141                   <xsl:apply-templates select="." mode="filename"/>
142                 </xsl:attribute>
143                 <xsl:apply-templates select="." mode="toc-title"/>
144               </a>
145             </span>
146             <br/>
147           </xsl:for-each>
148         </xsl:if>
149       </xsl:when>
150       <xsl:otherwise>
151         <img alt=" ">
152           <xsl:attribute name="src">
153             <xsl:call-template name="graphics-file">
154               <xsl:with-param name="image" select="$blank.image"/>
155             </xsl:call-template>
156           </xsl:attribute>
157         </img>
158         <span class="ttoc-foil">
159           <a>
160             <xsl:attribute name="href">
161               <xsl:apply-templates select="." mode="filename"/>
162             </xsl:attribute>
163             <xsl:apply-templates select="." mode="toc-title"/>
164           </a>
165         </span>
166         <br/>
167       </xsl:otherwise>
168     </xsl:choose>
169   </xsl:for-each>
170 </xsl:template>
171
172 <xsl:template match="foil" mode="t-toc">
173   <xsl:variable name="thisfoil" select="."/>
174
175   <xsl:for-each select="/slides/foil|/slides/foilgroup">
176     <xsl:choose>
177       <xsl:when test="name(.) = 'foilgroup'">
178         <img alt=" ">
179           <xsl:attribute name="src">
180             <xsl:call-template name="graphics-file">
181               <xsl:with-param name="image" select="$blank.image"/>
182             </xsl:call-template>
183           </xsl:attribute>
184         </img>
185         <span class="ttoc-foilgroup">
186           <a>
187             <xsl:attribute name="href">
188               <xsl:apply-templates select="." mode="filename"/>
189             </xsl:attribute>
190             <xsl:apply-templates select="." mode="toc-title"/>
191           </a>
192         </span>
193         <br/>
194
195         <xsl:if test="$thisfoil/ancestor::foilgroup = .">
196           <xsl:for-each select="foil">
197             <img alt=" ">
198               <xsl:attribute name="src">
199                 <xsl:call-template name="graphics-file">
200                   <xsl:with-param name="image" select="$blank.image"/>
201                 </xsl:call-template>
202               </xsl:attribute>
203             </img>
204
205             <xsl:choose>
206               <xsl:when test="$thisfoil = .">
207                 <img alt="+">
208                   <xsl:attribute name="src">
209                     <xsl:call-template name="graphics-file">
210                       <xsl:with-param name="image" select="$arrow.image"/>
211                     </xsl:call-template>
212                   </xsl:attribute>
213                 </img>
214               </xsl:when>
215               <xsl:otherwise>
216                 <img alt=" ">
217                   <xsl:attribute name="src">
218                     <xsl:call-template name="graphics-file">
219                       <xsl:with-param name="image" select="$blank.image"/>
220                     </xsl:call-template>
221                   </xsl:attribute>
222                 </img>
223               </xsl:otherwise>
224             </xsl:choose>
225
226             <span class="ttoc-foil">
227               <a>
228                 <xsl:attribute name="href">
229                   <xsl:apply-templates select="." mode="filename"/>
230                 </xsl:attribute>
231                 <xsl:apply-templates select="." mode="toc-title"/>
232               </a>
233             </span>
234             <br/>
235           </xsl:for-each>
236         </xsl:if>
237       </xsl:when>
238       <xsl:otherwise>
239         <!-- foils only -->
240         <xsl:for-each select="/slides/foil">
241           <xsl:choose>
242             <xsl:when test="$thisfoil = .">
243               <img alt="+">
244                 <xsl:attribute name="src">
245                   <xsl:call-template name="graphics-file">
246                     <xsl:with-param name="image" select="$arrow.image"/>
247                   </xsl:call-template>
248                 </xsl:attribute>
249               </img>
250             </xsl:when>
251             <xsl:otherwise>
252               <img alt=" ">
253                 <xsl:attribute name="src">
254                   <xsl:call-template name="graphics-file">
255                     <xsl:with-param name="image" select="$blank.image"/>
256                   </xsl:call-template>
257                 </xsl:attribute>
258               </img>
259             </xsl:otherwise>
260           </xsl:choose>
261           <span class="ttoc-foil">
262             <xsl:apply-templates select="." mode="toc-title"/>
263           </span>
264           <br/>
265         </xsl:for-each>
266       </xsl:otherwise>
267     </xsl:choose>
268   </xsl:for-each>
269 </xsl:template>
270
271 <!-- ============================================================ -->
272
273 <xsl:template match="slides" mode="toc-title">
274   <xsl:call-template name="nobreak">
275     <xsl:with-param name="string">
276       <xsl:choose>
277         <xsl:when test="slidesinfo/titleabbrev">
278           <xsl:value-of select="slidesinfo/titleabbrev"/>
279         </xsl:when>
280         <xsl:otherwise>
281           <xsl:value-of select="slidesinfo/title"/>
282         </xsl:otherwise>
283       </xsl:choose>
284     </xsl:with-param>
285   </xsl:call-template>
286 </xsl:template>
287
288 <xsl:template match="foilgroup" mode="toc-title">
289   <xsl:call-template name="nobreak">
290     <xsl:with-param name="string">
291       <xsl:choose>
292         <xsl:when test="titleabbrev">
293           <xsl:value-of select="titleabbrev"/>
294         </xsl:when>
295         <xsl:otherwise>
296           <xsl:value-of select="title"/>
297         </xsl:otherwise>
298       </xsl:choose>
299     </xsl:with-param>
300   </xsl:call-template>
301 </xsl:template>
302
303 <xsl:template match="foil" mode="toc-title">
304   <xsl:call-template name="nobreak">
305     <xsl:with-param name="string">
306       <xsl:choose>
307         <xsl:when test="titleabbrev">
308           <xsl:value-of select="titleabbrev"/>
309         </xsl:when>
310         <xsl:otherwise>
311           <xsl:value-of select="title"/>
312         </xsl:otherwise>
313       </xsl:choose>
314     </xsl:with-param>
315   </xsl:call-template>
316 </xsl:template>
317
318 <xsl:template name="nobreak">
319   <xsl:param name="string" select="''"/>
320   <xsl:choose>
321     <xsl:when test="contains($string, ' ')">
322       <xsl:value-of select="substring-before($string, ' ')"/>
323       <xsl:text>&#160;</xsl:text>
324       <xsl:call-template name="nobreak">
325         <xsl:with-param name="string" select="substring-after($string, ' ')"/>
326       </xsl:call-template>
327     </xsl:when>
328     <xsl:otherwise>
329       <xsl:value-of select="$string"/>
330     </xsl:otherwise>
331   </xsl:choose>
332 </xsl:template>
333
334 <!-- ============================================================ -->
335
336 </xsl:stylesheet>