2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: formal.xsl 8310 2009-03-11 08:29:45Z 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:copy-of select="$title"/>
100 <xsl:template name="informal.object">
101 <xsl:param name="class" select="local-name(.)"/>
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/>
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"/>
116 <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
120 <xsl:variable name="floatstyle">
121 <xsl:call-template name="floatstyle"/>
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"/>
134 <xsl:copy-of select="$content"/>
140 <xsl:template name="semiformal.object">
141 <xsl:param name="placement" select="'before'"/>
142 <xsl:param name="class" select="local-name(.)"/>
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"/>
152 <xsl:call-template name="informal.object">
153 <xsl:with-param name="class" select="$class"/>
159 <xsl:template match="figure">
160 <xsl:variable name="param.placement"
161 select="substring-after(normalize-space($formal.title.placement),
162 concat(local-name(.), ' '))"/>
164 <xsl:variable name="placement">
166 <xsl:when test="contains($param.placement, ' ')">
167 <xsl:value-of select="substring-before($param.placement, ' ')"/>
169 <xsl:when test="$param.placement = ''">before</xsl:when>
171 <xsl:value-of select="$param.placement"/>
176 <xsl:call-template name="formal.object">
177 <xsl:with-param name="placement" select="$placement"/>
182 <xsl:template match="table">
184 <xsl:when test="tgroup|mediaobject|graphic">
185 <xsl:call-template name="calsTable"/>
188 <!-- do not use xsl:copy because of XHTML's needs -->
189 <xsl:element name="table" namespace="">
190 <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
191 <xsl:attribute name="id">
192 <xsl:call-template name="object.id"/>
194 <xsl:call-template name="htmlTable"/>
200 <xsl:template name="calsTable">
201 <xsl:if test="tgroup/tbody/tr
204 <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
207 <xsl:variable name="param.placement"
208 select="substring-after(normalize-space($formal.title.placement),
209 concat(local-name(.), ' '))"/>
211 <xsl:variable name="placement">
213 <xsl:when test="contains($param.placement, ' ')">
214 <xsl:value-of select="substring-before($param.placement, ' ')"/>
216 <xsl:when test="$param.placement = ''">before</xsl:when>
218 <xsl:value-of select="$param.placement"/>
223 <xsl:call-template name="formal.object">
224 <xsl:with-param name="placement" select="$placement"/>
225 <xsl:with-param name="class">
227 <xsl:when test="@tabstyle">
228 <!-- hack, this will only ever occur on table, not example -->
229 <xsl:value-of select="@tabstyle"/>
232 <xsl:value-of select="local-name(.)"/>
239 <xsl:template name="htmlTable">
240 <xsl:if test="tgroup/tbody/row
243 <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
246 <xsl:apply-templates mode="htmlTable"/>
249 <xsl:template match="example">
250 <xsl:variable name="param.placement"
251 select="substring-after(normalize-space($formal.title.placement),
252 concat(local-name(.), ' '))"/>
254 <xsl:variable name="placement">
256 <xsl:when test="contains($param.placement, ' ')">
257 <xsl:value-of select="substring-before($param.placement, ' ')"/>
259 <xsl:when test="$param.placement = ''">before</xsl:when>
261 <xsl:value-of select="$param.placement"/>
266 <xsl:call-template name="formal.object">
267 <xsl:with-param name="placement" select="$placement"/>
272 <xsl:template match="equation">
273 <xsl:variable name="param.placement"
274 select="substring-after(normalize-space($formal.title.placement),
275 concat(local-name(.), ' '))"/>
277 <xsl:variable name="placement">
279 <xsl:when test="contains($param.placement, ' ')">
280 <xsl:value-of select="substring-before($param.placement, ' ')"/>
282 <xsl:when test="$param.placement = ''">before</xsl:when>
284 <xsl:value-of select="$param.placement"/>
289 <xsl:call-template name="formal.object">
290 <xsl:with-param name="placement" select="$placement"/>
295 <xsl:template match="figure/title"></xsl:template>
296 <xsl:template match="figure/titleabbrev"></xsl:template>
297 <xsl:template match="table/title"></xsl:template>
298 <xsl:template match="table/titleabbrev"></xsl:template>
299 <xsl:template match="table/textobject"></xsl:template>
300 <xsl:template match="example/title"></xsl:template>
301 <xsl:template match="example/titleabbrev"></xsl:template>
302 <xsl:template match="equation/title"></xsl:template>
303 <xsl:template match="equation/titleabbrev"></xsl:template>
305 <xsl:template match="informalfigure">
306 <xsl:call-template name="informal.object"/>
309 <xsl:template match="informalexample">
310 <xsl:call-template name="informal.object"/>
313 <xsl:template match="informaltable">
315 <xsl:when test="tgroup|mediaobject|graphic">
316 <xsl:call-template name="informal.object">
317 <xsl:with-param name="class">
319 <xsl:when test="@tabstyle">
320 <xsl:value-of select="@tabstyle"/>
323 <xsl:value-of select="local-name(.)"/>
330 <xsl:element name="table" namespace="">
331 <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
332 <xsl:attribute name="id">
333 <xsl:call-template name="object.id"/>
335 <xsl:call-template name="htmlTable"/>
341 <xsl:template match="informaltable/textobject"></xsl:template>
343 <xsl:template name="table.longdesc">
344 <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
345 <!-- the table template, but I want the link to be inside the DIV, so... -->
346 <xsl:variable name="longdesc.uri">
347 <xsl:call-template name="longdesc.uri">
348 <xsl:with-param name="mediaobject" select="."/>
352 <xsl:variable name="irrelevant">
353 <!-- write.longdesc returns the filename ... -->
354 <xsl:call-template name="write.longdesc">
355 <xsl:with-param name="mediaobject" select="."/>
359 <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0
360 and textobject[not(phrase)]">
361 <xsl:call-template name="longdesc.link">
362 <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
367 <xsl:template match="informalequation">
368 <xsl:call-template name="informal.object"/>
371 <xsl:template name="floatstyle">
372 <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
374 <xsl:when test="@floatstyle != ''">
375 <xsl:value-of select="@floatstyle"/>
377 <xsl:when test="@float = '1'">
378 <xsl:value-of select="$default.float.class"/>
381 <xsl:value-of select="@float"/>
387 <xsl:template name="floater">
388 <xsl:param name="content"/>
389 <xsl:param name="class" select="'float'"/>
390 <xsl:param name="floatstyle" select="'left'"/>
392 <div class="{$class}">
393 <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
394 <xsl:attribute name="style">
395 <xsl:text>float: </xsl:text>
396 <xsl:value-of select="$floatstyle"/>
397 <xsl:text>;</xsl:text>
400 <xsl:copy-of select="$content"/>