2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: formal.xsl 8806 2010-08-09 18:25:58Z bobstayton $
7 ********************************************************************
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.
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="anchor">
28 <xsl:with-param name="conditional" select="0"/>
32 <xsl:when test="$placement = 'before'">
33 <xsl:call-template name="formal.object.heading"/>
34 <div class="{$class}-contents">
35 <xsl:apply-templates/>
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"/>
44 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
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"/>
56 <xsl:call-template name="formal.object.heading"/>
60 <xsl:if test="not($formal.object.break.after = '0')">
61 <br class="{$class}-break"/>
65 <xsl:variable name="floatstyle">
66 <xsl:call-template name="floatstyle"/>
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"/>
79 <xsl:copy-of select="$content"/>
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>
95 <xsl:when test="$make.clean.html != 0">
96 <xsl:variable name="html.class" select="concat(local-name($object),'-title')"/>
97 <div class="{$html.class}">
98 <xsl:copy-of select="$title"/>
104 <xsl:copy-of select="$title"/>
111 <xsl:template name="informal.object">
112 <xsl:param name="class" select="local-name(.)"/>
114 <xsl:variable name="content">
115 <div class="{$class}">
116 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
117 <xsl:call-template name="anchor"/>
118 <xsl:apply-templates/>
120 <!-- HACK: This doesn't belong inside formal.object; it
121 should be done by the table template, but I want
122 the link to be inside the DIV, so... -->
123 <xsl:if test="local-name(.) = 'informaltable'">
124 <xsl:call-template name="table.longdesc"/>
127 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
131 <xsl:variable name="floatstyle">
132 <xsl:call-template name="floatstyle"/>
136 <xsl:when test="$floatstyle != ''">
137 <xsl:call-template name="floater">
138 <xsl:with-param name="class"><xsl:value-of
139 select="$class"/>-float</xsl:with-param>
140 <xsl:with-param name="floatstyle" select="$floatstyle"/>
141 <xsl:with-param name="content" select="$content"/>
145 <xsl:copy-of select="$content"/>
151 <xsl:template name="semiformal.object">
152 <xsl:param name="placement" select="'before'"/>
153 <xsl:param name="class" select="local-name(.)"/>
156 <xsl:when test="title or info/title">
157 <xsl:call-template name="formal.object">
158 <xsl:with-param name="placement" select="$placement"/>
159 <xsl:with-param name="class" select="$class"/>
163 <xsl:call-template name="informal.object">
164 <xsl:with-param name="class" select="$class"/>
170 <xsl:template match="figure">
171 <xsl:variable name="param.placement"
172 select="substring-after(normalize-space($formal.title.placement),
173 concat(local-name(.), ' '))"/>
175 <xsl:variable name="placement">
177 <xsl:when test="contains($param.placement, ' ')">
178 <xsl:value-of select="substring-before($param.placement, ' ')"/>
180 <xsl:when test="$param.placement = ''">before</xsl:when>
182 <xsl:value-of select="$param.placement"/>
187 <xsl:call-template name="formal.object">
188 <xsl:with-param name="placement" select="$placement"/>
193 <xsl:template match="table">
195 <xsl:when test="tgroup|mediaobject|graphic">
196 <xsl:call-template name="calsTable"/>
199 <!-- do not use xsl:copy because of XHTML's needs -->
200 <xsl:element name="table" namespace="">
201 <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
202 <xsl:attribute name="id">
203 <xsl:call-template name="object.id"/>
205 <xsl:call-template name="htmlTable"/>
211 <xsl:template name="calsTable">
212 <xsl:if test="tgroup/tbody/tr
215 <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
218 <xsl:variable name="param.placement"
219 select="substring-after(normalize-space($formal.title.placement),
220 concat(local-name(.), ' '))"/>
222 <xsl:variable name="placement">
224 <xsl:when test="contains($param.placement, ' ')">
225 <xsl:value-of select="substring-before($param.placement, ' ')"/>
227 <xsl:when test="$param.placement = ''">before</xsl:when>
229 <xsl:value-of select="$param.placement"/>
234 <xsl:call-template name="formal.object">
235 <xsl:with-param name="placement" select="$placement"/>
236 <xsl:with-param name="class">
238 <xsl:when test="@tabstyle">
239 <!-- hack, this will only ever occur on table, not example -->
240 <xsl:value-of select="@tabstyle"/>
243 <xsl:value-of select="local-name(.)"/>
250 <xsl:template name="htmlTable">
251 <xsl:if test="tgroup/tbody/row
254 <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
257 <xsl:apply-templates mode="htmlTable"/>
259 <xsl:if test=".//footnote|../title//footnote">
260 <tbody class="footnotes">
263 <xsl:apply-templates select=".//footnote|../title//footnote" mode="table.footnote.mode"/>
270 <xsl:template match="example">
271 <xsl:variable name="param.placement"
272 select="substring-after(normalize-space($formal.title.placement),
273 concat(local-name(.), ' '))"/>
275 <xsl:variable name="placement">
277 <xsl:when test="contains($param.placement, ' ')">
278 <xsl:value-of select="substring-before($param.placement, ' ')"/>
280 <xsl:when test="$param.placement = ''">before</xsl:when>
282 <xsl:value-of select="$param.placement"/>
287 <xsl:call-template name="formal.object">
288 <xsl:with-param name="placement" select="$placement"/>
293 <xsl:template match="equation">
294 <xsl:variable name="param.placement"
295 select="substring-after(normalize-space($formal.title.placement),
296 concat(local-name(.), ' '))"/>
298 <xsl:variable name="placement">
300 <xsl:when test="contains($param.placement, ' ')">
301 <xsl:value-of select="substring-before($param.placement, ' ')"/>
303 <xsl:when test="$param.placement = ''">before</xsl:when>
305 <xsl:value-of select="$param.placement"/>
310 <xsl:call-template name="formal.object">
311 <xsl:with-param name="placement" select="$placement"/>
316 <xsl:template match="figure/title"></xsl:template>
317 <xsl:template match="figure/titleabbrev"></xsl:template>
318 <xsl:template match="table/title"></xsl:template>
319 <xsl:template match="table/titleabbrev"></xsl:template>
320 <xsl:template match="table/textobject"></xsl:template>
321 <xsl:template match="example/title"></xsl:template>
322 <xsl:template match="example/titleabbrev"></xsl:template>
323 <xsl:template match="equation/title"></xsl:template>
324 <xsl:template match="equation/titleabbrev"></xsl:template>
326 <xsl:template match="informalfigure">
327 <xsl:call-template name="informal.object"/>
330 <xsl:template match="informalexample">
331 <xsl:call-template name="informal.object"/>
334 <xsl:template match="informaltable">
336 <xsl:when test="tgroup|mediaobject|graphic">
337 <xsl:call-template name="informal.object">
338 <xsl:with-param name="class">
340 <xsl:when test="@tabstyle">
341 <xsl:value-of select="@tabstyle"/>
344 <xsl:value-of select="local-name(.)"/>
351 <xsl:element name="table" namespace="">
352 <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
353 <xsl:attribute name="id">
354 <xsl:call-template name="object.id"/>
356 <xsl:call-template name="htmlTable"/>
362 <xsl:template match="informaltable/textobject"></xsl:template>
364 <xsl:template name="table.longdesc">
365 <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
366 <!-- the table template, but I want the link to be inside the DIV, so... -->
367 <xsl:variable name="longdesc.uri">
368 <xsl:call-template name="longdesc.uri">
369 <xsl:with-param name="mediaobject" select="."/>
373 <xsl:variable name="irrelevant">
374 <!-- write.longdesc returns the filename ... -->
375 <xsl:call-template name="write.longdesc">
376 <xsl:with-param name="mediaobject" select="."/>
380 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0
381 and textobject[not(phrase)]">
382 <xsl:call-template name="longdesc.link">
383 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
388 <xsl:template match="informalequation">
389 <xsl:call-template name="informal.object"/>
392 <xsl:template name="floatstyle">
393 <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
395 <xsl:when test="@floatstyle != ''">
396 <xsl:value-of select="@floatstyle"/>
398 <xsl:when test="@float = '1'">
399 <xsl:value-of select="$default.float.class"/>
402 <xsl:value-of select="@float"/>
408 <xsl:template name="floater">
409 <xsl:param name="content"/>
410 <xsl:param name="class" select="'float'"/>
411 <xsl:param name="floatstyle" select="'left'"/>
413 <div class="{$class}">
414 <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
415 <xsl:attribute name="style">
416 <xsl:text>float: </xsl:text>
417 <xsl:value-of select="$floatstyle"/>
418 <xsl:text>;</xsl:text>
421 <xsl:copy-of select="$content"/>