2 <xsl:stylesheet exclude-result-prefixes="d"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:d="http://docbook.org/ns/docbook"
7 <!-- ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://cdn.docbook.org/release/xsl/current/ for
11 copyright 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">
20 <xsl:apply-templates select="." mode="class.value"/>
23 <xsl:call-template name="id.warning"/>
25 <xsl:variable name="content">
26 <div class="{$class}">
27 <xsl:call-template name="id.attribute">
28 <xsl:with-param name="conditional" select="0"/>
30 <xsl:call-template name="anchor">
31 <xsl:with-param name="conditional" select="0"/>
35 <xsl:when test="$placement = 'before'">
36 <xsl:call-template name="formal.object.heading"/>
37 <div class="{$class}-contents">
38 <xsl:apply-templates/>
40 <!-- HACK: This doesn't belong inside formal.object; it
41 should be done by the table template, but I want
42 the link to be inside the DIV, so... -->
43 <xsl:if test="local-name(.) = 'table'">
44 <xsl:call-template name="table.longdesc"/>
47 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
50 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
51 <div class="{$class}-contents"><xsl:apply-templates/></div>
52 <!-- HACK: This doesn't belong inside formal.object; it
53 should be done by the table template, but I want
54 the link to be inside the DIV, so... -->
55 <xsl:if test="local-name(.) = 'table'">
56 <xsl:call-template name="table.longdesc"/>
59 <xsl:call-template name="formal.object.heading"/>
63 <xsl:if test="not($formal.object.break.after = '0')">
64 <br class="{$class}-break"/>
68 <xsl:variable name="floatstyle">
69 <xsl:call-template name="floatstyle"/>
73 <xsl:when test="$floatstyle != ''">
74 <xsl:call-template name="floater">
75 <xsl:with-param name="class"><xsl:value-of
76 select="$class"/>-float</xsl:with-param>
77 <xsl:with-param name="floatstyle" select="$floatstyle"/>
78 <xsl:with-param name="content" select="$content"/>
82 <xsl:copy-of select="$content"/>
88 <xsl:template name="formal.object.heading">
89 <xsl:param name="object" select="."/>
90 <xsl:param name="title">
91 <xsl:apply-templates select="$object" mode="object.title.markup">
92 <xsl:with-param name="allow-anchors" select="1"/>
93 </xsl:apply-templates>
98 <xsl:when test="$make.clean.html != 0">
99 <xsl:variable name="html.class" select="concat(local-name($object),'-title')"/>
100 <div class="{$html.class}">
101 <xsl:copy-of select="$title"/>
107 <xsl:copy-of select="$title"/>
114 <xsl:template name="informal.object">
115 <xsl:param name="class">
116 <xsl:apply-templates select="." mode="class.value"/>
119 <xsl:variable name="content">
120 <div class="{$class}">
121 <xsl:call-template name="id.attribute"/>
122 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
123 <xsl:call-template name="anchor"/>
124 <xsl:apply-templates/>
126 <!-- HACK: This doesn't belong inside formal.object; it
127 should be done by the table template, but I want
128 the link to be inside the DIV, so... -->
129 <xsl:if test="local-name(.) = 'informaltable'">
130 <xsl:call-template name="table.longdesc"/>
133 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
137 <xsl:variable name="floatstyle">
138 <xsl:call-template name="floatstyle"/>
142 <xsl:when test="$floatstyle != ''">
143 <xsl:call-template name="floater">
144 <xsl:with-param name="class"><xsl:value-of
145 select="$class"/>-float</xsl:with-param>
146 <xsl:with-param name="floatstyle" select="$floatstyle"/>
147 <xsl:with-param name="content" select="$content"/>
151 <xsl:copy-of select="$content"/>
157 <xsl:template name="semiformal.object">
158 <xsl:param name="placement" select="'before'"/>
159 <xsl:param name="class" select="local-name(.)"/>
162 <xsl:when test="d:title or d:info/d:title">
163 <xsl:call-template name="formal.object">
164 <xsl:with-param name="placement" select="$placement"/>
165 <xsl:with-param name="class" select="$class"/>
169 <xsl:call-template name="informal.object">
170 <xsl:with-param name="class" select="$class"/>
176 <xsl:template match="d:figure">
177 <xsl:variable name="param.placement"
178 select="substring-after(normalize-space($formal.title.placement),
179 concat(local-name(.), ' '))"/>
181 <xsl:variable name="placement">
183 <xsl:when test="contains($param.placement, ' ')">
184 <xsl:value-of select="substring-before($param.placement, ' ')"/>
186 <xsl:when test="$param.placement = ''">before</xsl:when>
188 <xsl:value-of select="$param.placement"/>
193 <xsl:call-template name="formal.object">
194 <xsl:with-param name="placement" select="$placement"/>
199 <xsl:template match="d:table">
201 <xsl:when test="d:tgroup|d:mediaobject|d:graphic">
202 <xsl:call-template name="calsTable"/>
204 <xsl:when test="d:caption">
205 <xsl:call-template name="htmlTable.with.caption"/>
208 <!-- do not use xsl:copy because of XHTML's needs -->
210 <xsl:call-template name="generate.class.attribute"/>
211 <xsl:call-template name="id.attribute"/>
212 <xsl:call-template name="anchor"/>
213 <xsl:element name="table" namespace="">
214 <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
215 <xsl:call-template name="htmlTable"/>
222 <!-- Handle html markup table like formal.object -->
223 <xsl:template name="htmlTable.with.caption">
224 <xsl:param name="class">
225 <xsl:apply-templates select="." mode="class.value"/>
228 <xsl:variable name="param.placement"
229 select="substring-after(normalize-space($formal.title.placement),
230 concat(local-name(.), ' '))"/>
232 <xsl:variable name="placement">
234 <xsl:when test="contains($param.placement, ' ')">
235 <xsl:value-of select="substring-before($param.placement, ' ')"/>
237 <xsl:when test="$param.placement = ''">before</xsl:when>
239 <xsl:value-of select="$param.placement"/>
244 <xsl:call-template name="id.warning"/>
246 <xsl:variable name="content">
247 <div class="{$class}">
248 <xsl:call-template name="id.attribute">
249 <xsl:with-param name="conditional" select="0"/>
251 <xsl:call-template name="anchor">
252 <xsl:with-param name="conditional" select="0"/>
256 <xsl:when test="$placement = 'before'">
258 <xsl:call-template name="formal.object.heading"/>
260 <div class="{$class}-contents">
261 <xsl:apply-templates select="." mode="htmlTable"/>
264 <xsl:call-template name="table.longdesc"/>
266 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
269 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
271 <div class="{$class}-contents">
272 <xsl:apply-templates select="." mode="htmlTable"/>
275 <xsl:call-template name="table.longdesc"/>
277 <xsl:call-template name="formal.object.heading"/>
281 <xsl:if test="not($formal.object.break.after = '0')">
282 <br class="{$class}-break"/>
286 <xsl:variable name="floatstyle">
287 <xsl:call-template name="floatstyle"/>
291 <xsl:when test="$floatstyle != ''">
292 <xsl:call-template name="floater">
293 <xsl:with-param name="class"><xsl:value-of
294 select="$class"/>-float</xsl:with-param>
295 <xsl:with-param name="floatstyle" select="$floatstyle"/>
296 <xsl:with-param name="content" select="$content"/>
300 <xsl:copy-of select="$content"/>
306 <xsl:template name="calsTable">
307 <xsl:if test="d:tgroup/d:tbody/d:tr
308 |d:tgroup/d:thead/d:tr
309 |d:tgroup/d:tfoot/d:tr">
310 <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
313 <xsl:variable name="param.placement"
314 select="substring-after(normalize-space($formal.title.placement),
315 concat(local-name(.), ' '))"/>
317 <xsl:variable name="placement">
319 <xsl:when test="contains($param.placement, ' ')">
320 <xsl:value-of select="substring-before($param.placement, ' ')"/>
322 <xsl:when test="$param.placement = ''">before</xsl:when>
324 <xsl:value-of select="$param.placement"/>
329 <xsl:call-template name="formal.object">
330 <xsl:with-param name="placement" select="$placement"/>
334 <xsl:template match="d:table|d:informaltable" mode="class.value">
336 <xsl:when test="@tabstyle">
337 <xsl:value-of select="@tabstyle"/>
340 <xsl:value-of select="local-name(.)"/>
345 <xsl:template name="htmlTable">
346 <xsl:if test="d:tgroup/d:tbody/d:row
347 |d:tgroup/d:thead/d:row
348 |d:tgroup/d:tfoot/d:row">
349 <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
352 <xsl:apply-templates mode="htmlTable"/>
354 <xsl:if test=".//d:footnote|../d:title//d:footnote">
355 <tbody class="footnotes">
358 <xsl:apply-templates select=".//d:footnote|../d:title//d:footnote" mode="table.footnote.mode"/>
365 <xsl:template match="d:example">
366 <xsl:variable name="param.placement"
367 select="substring-after(normalize-space($formal.title.placement),
368 concat(local-name(.), ' '))"/>
370 <xsl:variable name="placement">
372 <xsl:when test="contains($param.placement, ' ')">
373 <xsl:value-of select="substring-before($param.placement, ' ')"/>
375 <xsl:when test="$param.placement = ''">before</xsl:when>
377 <xsl:value-of select="$param.placement"/>
382 <xsl:call-template name="formal.object">
383 <xsl:with-param name="placement" select="$placement"/>
388 <xsl:template match="d:equation">
389 <xsl:variable name="param.placement"
390 select="substring-after(normalize-space($formal.title.placement),
391 concat(local-name(.), ' '))"/>
393 <xsl:variable name="placement">
395 <xsl:when test="contains($param.placement, ' ')">
396 <xsl:value-of select="substring-before($param.placement, ' ')"/>
398 <xsl:when test="$param.placement = ''">before</xsl:when>
400 <xsl:value-of select="$param.placement"/>
405 <xsl:call-template name="formal.object">
406 <xsl:with-param name="placement" select="$placement"/>
411 <xsl:template match="d:figure/d:title"></xsl:template>
412 <xsl:template match="d:figure/d:titleabbrev"></xsl:template>
413 <xsl:template match="d:table/d:title"></xsl:template>
414 <xsl:template match="d:table/d:titleabbrev"></xsl:template>
415 <xsl:template match="d:table/d:textobject"></xsl:template>
416 <xsl:template match="d:example/d:title"></xsl:template>
417 <xsl:template match="d:example/d:titleabbrev"></xsl:template>
418 <xsl:template match="d:equation/d:title"></xsl:template>
419 <xsl:template match="d:equation/d:titleabbrev"></xsl:template>
421 <xsl:template match="d:informalfigure">
422 <xsl:call-template name="informal.object"/>
425 <xsl:template match="d:informalexample">
426 <xsl:call-template name="informal.object"/>
429 <xsl:template match="d:informaltable">
431 <xsl:when test="d:tgroup|d:mediaobject|d:graphic">
432 <xsl:call-template name="informal.object"/>
436 <xsl:call-template name="generate.class.attribute"/>
437 <xsl:call-template name="id.attribute"/>
438 <xsl:call-template name="anchor"/>
439 <xsl:element name="table" namespace="">
440 <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
441 <xsl:call-template name="htmlTable"/>
448 <xsl:template match="d:informaltable/d:textobject"></xsl:template>
450 <xsl:template name="table.longdesc">
451 <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
452 <!-- the table template, but I want the link to be inside the DIV, so... -->
453 <xsl:variable name="longdesc.uri">
454 <xsl:call-template name="longdesc.uri">
455 <xsl:with-param name="mediaobject" select="."/>
459 <xsl:variable name="irrelevant">
460 <!-- write.longdesc returns the filename ... -->
461 <xsl:call-template name="write.longdesc">
462 <xsl:with-param name="mediaobject" select="."/>
466 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0
467 and d:textobject[not(d:phrase)]">
468 <xsl:call-template name="longdesc.link">
469 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
474 <xsl:template match="d:informalequation">
475 <xsl:call-template name="informal.object"/>
478 <xsl:template name="floatstyle">
479 <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
481 <xsl:when test="@floatstyle != ''">
482 <xsl:value-of select="@floatstyle"/>
484 <xsl:when test="@float = '1'">
485 <xsl:value-of select="$default.float.class"/>
488 <xsl:value-of select="@float"/>
494 <xsl:template name="floater">
495 <xsl:param name="content"/>
496 <xsl:param name="class" select="'float'"/>
497 <xsl:param name="floatstyle" select="'left'"/>
499 <div class="{$class}">
500 <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
501 <xsl:attribute name="style">
502 <xsl:text>float: </xsl:text>
503 <xsl:value-of select="$floatstyle"/>
504 <xsl:text>;</xsl:text>
507 <xsl:copy-of select="$content"/>