Jitterbug no more.
[fvwm.git] / doc / docbook-xsl / html / formal.xsl
blob2d8befd433fa2a459ae14ecdb8738d3e0b4ffaf9
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version='1.0'>
5 <!-- ********************************************************************
6 $Id: formal.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
13 ******************************************************************** -->
15 <xsl:param name="formal.object.break.after">1</xsl:param>
17 <xsl:template name="formal.object">
18 <xsl:param name="placement" select="'before'"/>
19 <xsl:param name="class" select="local-name(.)"/>
21 <xsl:call-template name="id.warning"/>
23 <xsl:variable name="content">
24 <div class="{$class}">
25 <xsl:call-template name="anchor">
26 <xsl:with-param name="conditional" select="0"/>
27 </xsl:call-template>
29 <xsl:choose>
30 <xsl:when test="$placement = 'before'">
31 <xsl:call-template name="formal.object.heading"/>
32 <div class="{$class}-contents">
33 <xsl:apply-templates/>
34 </div>
35 <!-- HACK: This doesn't belong inside formal.object; it
36 should be done by the table template, but I want
37 the link to be inside the DIV, so... -->
38 <xsl:if test="local-name(.) = 'table'">
39 <xsl:call-template name="table.longdesc"/>
40 </xsl:if>
42 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
43 </xsl:when>
44 <xsl:otherwise>
45 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
46 <div class="{$class}-contents"><xsl:apply-templates/></div>
47 <!-- HACK: This doesn't belong inside formal.object; it
48 should be done by the table template, but I want
49 the link to be inside the DIV, so... -->
50 <xsl:if test="local-name(.) = 'table'">
51 <xsl:call-template name="table.longdesc"/>
52 </xsl:if>
54 <xsl:call-template name="formal.object.heading"/>
55 </xsl:otherwise>
56 </xsl:choose>
57 </div>
58 <xsl:if test="not($formal.object.break.after = '0')">
59 <br class="{$class}-break"/>
60 </xsl:if>
61 </xsl:variable>
63 <xsl:variable name="floatstyle">
64 <xsl:call-template name="floatstyle"/>
65 </xsl:variable>
67 <xsl:choose>
68 <xsl:when test="$floatstyle != ''">
69 <xsl:call-template name="floater">
70 <xsl:with-param name="class"><xsl:value-of
71 select="$class"/>-float</xsl:with-param>
72 <xsl:with-param name="floatstyle" select="$floatstyle"/>
73 <xsl:with-param name="content" select="$content"/>
74 </xsl:call-template>
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:copy-of select="$content"/>
78 </xsl:otherwise>
79 </xsl:choose>
81 </xsl:template>
83 <xsl:template name="formal.object.heading">
84 <xsl:param name="object" select="."/>
85 <xsl:param name="title">
86 <xsl:apply-templates select="$object" mode="object.title.markup">
87 <xsl:with-param name="allow-anchors" select="1"/>
88 </xsl:apply-templates>
89 </xsl:param>
91 <p class="title">
92 <b>
93 <xsl:copy-of select="$title"/>
94 </b>
95 </p>
96 </xsl:template>
98 <xsl:template name="informal.object">
99 <xsl:param name="class" select="local-name(.)"/>
101 <xsl:variable name="content">
102 <div class="{$class}">
103 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
104 <xsl:call-template name="anchor"/>
105 <xsl:apply-templates/>
107 <!-- HACK: This doesn't belong inside formal.object; it
108 should be done by the table template, but I want
109 the link to be inside the DIV, so... -->
110 <xsl:if test="local-name(.) = 'informaltable'">
111 <xsl:call-template name="table.longdesc"/>
112 </xsl:if>
114 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
115 </div>
116 </xsl:variable>
118 <xsl:variable name="floatstyle">
119 <xsl:call-template name="floatstyle"/>
120 </xsl:variable>
122 <xsl:choose>
123 <xsl:when test="$floatstyle != ''">
124 <xsl:call-template name="floater">
125 <xsl:with-param name="class"><xsl:value-of
126 select="$class"/>-float</xsl:with-param>
127 <xsl:with-param name="floatstyle" select="$floatstyle"/>
128 <xsl:with-param name="content" select="$content"/>
129 </xsl:call-template>
130 </xsl:when>
131 <xsl:otherwise>
132 <xsl:copy-of select="$content"/>
133 </xsl:otherwise>
134 </xsl:choose>
136 </xsl:template>
138 <xsl:template name="semiformal.object">
139 <xsl:param name="placement" select="'before'"/>
140 <xsl:param name="class" select="local-name(.)"/>
142 <xsl:choose>
143 <xsl:when test="title">
144 <xsl:call-template name="formal.object">
145 <xsl:with-param name="placement" select="$placement"/>
146 <xsl:with-param name="class" select="$class"/>
147 </xsl:call-template>
148 </xsl:when>
149 <xsl:otherwise>
150 <xsl:call-template name="informal.object">
151 <xsl:with-param name="class" select="$class"/>
152 </xsl:call-template>
153 </xsl:otherwise>
154 </xsl:choose>
155 </xsl:template>
157 <xsl:template match="figure">
158 <xsl:variable name="param.placement"
159 select="substring-after(normalize-space($formal.title.placement),
160 concat(local-name(.), ' '))"/>
162 <xsl:variable name="placement">
163 <xsl:choose>
164 <xsl:when test="contains($param.placement, ' ')">
165 <xsl:value-of select="substring-before($param.placement, ' ')"/>
166 </xsl:when>
167 <xsl:when test="$param.placement = ''">before</xsl:when>
168 <xsl:otherwise>
169 <xsl:value-of select="$param.placement"/>
170 </xsl:otherwise>
171 </xsl:choose>
172 </xsl:variable>
174 <xsl:call-template name="formal.object">
175 <xsl:with-param name="placement" select="$placement"/>
176 </xsl:call-template>
178 </xsl:template>
180 <xsl:template match="table">
181 <xsl:choose>
182 <xsl:when test="tgroup|mediaobject|graphic">
183 <xsl:call-template name="calsTable"/>
184 </xsl:when>
185 <xsl:otherwise>
186 <xsl:copy>
187 <xsl:copy-of select="@*[not(local-name()='id')]"/>
188 <xsl:attribute name="id">
189 <xsl:call-template name="object.id"/>
190 </xsl:attribute>
191 <xsl:call-template name="htmlTable"/>
192 </xsl:copy>
193 </xsl:otherwise>
194 </xsl:choose>
195 </xsl:template>
197 <xsl:template name="calsTable">
198 <xsl:if test="tgroup/tbody/tr
199 |tgroup/thead/tr
200 |tgroup/tfoot/tr">
201 <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
202 </xsl:if>
204 <xsl:variable name="param.placement"
205 select="substring-after(normalize-space($formal.title.placement),
206 concat(local-name(.), ' '))"/>
208 <xsl:variable name="placement">
209 <xsl:choose>
210 <xsl:when test="contains($param.placement, ' ')">
211 <xsl:value-of select="substring-before($param.placement, ' ')"/>
212 </xsl:when>
213 <xsl:when test="$param.placement = ''">before</xsl:when>
214 <xsl:otherwise>
215 <xsl:value-of select="$param.placement"/>
216 </xsl:otherwise>
217 </xsl:choose>
218 </xsl:variable>
220 <xsl:call-template name="formal.object">
221 <xsl:with-param name="placement" select="$placement"/>
222 <xsl:with-param name="class">
223 <xsl:choose>
224 <xsl:when test="@tabstyle">
225 <!-- hack, this will only ever occur on table, not example -->
226 <xsl:value-of select="@tabstyle"/>
227 </xsl:when>
228 <xsl:otherwise>
229 <xsl:value-of select="local-name(.)"/>
230 </xsl:otherwise>
231 </xsl:choose>
232 </xsl:with-param>
233 </xsl:call-template>
234 </xsl:template>
236 <xsl:template name="htmlTable">
237 <xsl:if test="tgroup/tbody/row
238 |tgroup/thead/row
239 |tgroup/tfoot/row">
240 <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
241 </xsl:if>
243 <xsl:apply-templates mode="htmlTable"/>
244 </xsl:template>
246 <xsl:template match="example">
247 <xsl:variable name="param.placement"
248 select="substring-after(normalize-space($formal.title.placement),
249 concat(local-name(.), ' '))"/>
251 <xsl:variable name="placement">
252 <xsl:choose>
253 <xsl:when test="contains($param.placement, ' ')">
254 <xsl:value-of select="substring-before($param.placement, ' ')"/>
255 </xsl:when>
256 <xsl:when test="$param.placement = ''">before</xsl:when>
257 <xsl:otherwise>
258 <xsl:value-of select="$param.placement"/>
259 </xsl:otherwise>
260 </xsl:choose>
261 </xsl:variable>
263 <xsl:call-template name="formal.object">
264 <xsl:with-param name="placement" select="$placement"/>
265 </xsl:call-template>
267 </xsl:template>
269 <xsl:template match="equation">
270 <xsl:variable name="param.placement"
271 select="substring-after(normalize-space($formal.title.placement),
272 concat(local-name(.), ' '))"/>
274 <xsl:variable name="placement">
275 <xsl:choose>
276 <xsl:when test="contains($param.placement, ' ')">
277 <xsl:value-of select="substring-before($param.placement, ' ')"/>
278 </xsl:when>
279 <xsl:when test="$param.placement = ''">before</xsl:when>
280 <xsl:otherwise>
281 <xsl:value-of select="$param.placement"/>
282 </xsl:otherwise>
283 </xsl:choose>
284 </xsl:variable>
286 <xsl:call-template name="formal.object">
287 <xsl:with-param name="placement" select="$placement"/>
288 </xsl:call-template>
290 </xsl:template>
292 <xsl:template match="figure/title"></xsl:template>
293 <xsl:template match="figure/titleabbrev"></xsl:template>
294 <xsl:template match="table/title"></xsl:template>
295 <xsl:template match="table/titleabbrev"></xsl:template>
296 <xsl:template match="table/textobject"></xsl:template>
297 <xsl:template match="example/title"></xsl:template>
298 <xsl:template match="example/titleabbrev"></xsl:template>
299 <xsl:template match="equation/title"></xsl:template>
300 <xsl:template match="equation/titleabbrev"></xsl:template>
302 <xsl:template match="informalfigure">
303 <xsl:call-template name="informal.object"/>
304 </xsl:template>
306 <xsl:template match="informalexample">
307 <xsl:call-template name="informal.object"/>
308 </xsl:template>
310 <xsl:template match="informaltable">
311 <xsl:choose>
312 <xsl:when test="tgroup|mediaobject|graphic">
313 <xsl:call-template name="informal.object">
314 <xsl:with-param name="class">
315 <xsl:choose>
316 <xsl:when test="@tabstyle">
317 <xsl:value-of select="@tabstyle"/>
318 </xsl:when>
319 <xsl:otherwise>
320 <xsl:value-of select="local-name(.)"/>
321 </xsl:otherwise>
322 </xsl:choose>
323 </xsl:with-param>
324 </xsl:call-template>
325 </xsl:when>
326 <xsl:otherwise>
327 <table>
328 <xsl:copy-of select="@*"/>
329 <xsl:call-template name="htmlTable"/>
330 </table>
331 </xsl:otherwise>
332 </xsl:choose>
333 </xsl:template>
335 <xsl:template match="informaltable/textobject"></xsl:template>
337 <xsl:template name="table.longdesc">
338 <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
339 <!-- the table template, but I want the link to be inside the DIV, so... -->
340 <xsl:variable name="longdesc.uri">
341 <xsl:call-template name="longdesc.uri">
342 <xsl:with-param name="mediaobject" select="."/>
343 </xsl:call-template>
344 </xsl:variable>
346 <xsl:variable name="irrelevant">
347 <!-- write.longdesc returns the filename ... -->
348 <xsl:call-template name="write.longdesc">
349 <xsl:with-param name="mediaobject" select="."/>
350 </xsl:call-template>
351 </xsl:variable>
353 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0
354 and textobject[not(phrase)]">
355 <xsl:call-template name="longdesc.link">
356 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
357 </xsl:call-template>
358 </xsl:if>
359 </xsl:template>
361 <xsl:template match="informalequation">
362 <xsl:call-template name="informal.object"/>
363 </xsl:template>
365 <xsl:template name="floatstyle">
366 <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
367 <xsl:choose>
368 <xsl:when test="@floatstyle != ''">
369 <xsl:value-of select="@floatstyle"/>
370 </xsl:when>
371 <xsl:when test="@float = '1'">
372 <xsl:value-of select="$default.float.class"/>
373 </xsl:when>
374 <xsl:otherwise>
375 <xsl:value-of select="@float"/>
376 </xsl:otherwise>
377 </xsl:choose>
378 </xsl:if>
379 </xsl:template>
381 <xsl:template name="floater">
382 <xsl:param name="content"/>
383 <xsl:param name="class" select="'float'"/>
384 <xsl:param name="floatstyle" select="'left'"/>
386 <div class="{$class}">
387 <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
388 <xsl:attribute name="style">
389 <xsl:text>float: </xsl:text>
390 <xsl:value-of select="$floatstyle"/>
391 <xsl:text>;</xsl:text>
392 </xsl:attribute>
393 </xsl:if>
394 <xsl:copy-of select="$content"/>
395 </div>
396 </xsl:template>
398 </xsl:stylesheet>