Debian Codegraph @

docs/xsl-generic/html/formal.xsl

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