2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
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"/>
30 <xsl:when test=
"$placement = 'before'">
31 <xsl:call-template name=
"formal.object.heading"/>
32 <div class=
"{$class}-contents">
33 <xsl:apply-templates/>
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"/>
42 <xsl:if test=
"$spacing.paras != 0"><p/></xsl:if>
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"/>
54 <xsl:call-template name=
"formal.object.heading"/>
58 <xsl:if test=
"not($formal.object.break.after = '0')">
59 <br class=
"{$class}-break"/>
63 <xsl:variable name=
"floatstyle">
64 <xsl:call-template name=
"floatstyle"/>
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"/>
77 <xsl:copy-of select=
"$content"/>
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>
93 <xsl:copy-of select=
"$title"/>
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"/>
114 <xsl:if test=
"$spacing.paras != 0"><p/></xsl:if>
118 <xsl:variable name=
"floatstyle">
119 <xsl:call-template name=
"floatstyle"/>
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"/>
132 <xsl:copy-of select=
"$content"/>
138 <xsl:template name=
"semiformal.object">
139 <xsl:param name=
"placement" select=
"'before'"/>
140 <xsl:param name=
"class" select=
"local-name(.)"/>
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"/>
150 <xsl:call-template name=
"informal.object">
151 <xsl:with-param name=
"class" select=
"$class"/>
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">
164 <xsl:when test=
"contains($param.placement, ' ')">
165 <xsl:value-of select=
"substring-before($param.placement, ' ')"/>
167 <xsl:when test=
"$param.placement = ''">before
</xsl:when>
169 <xsl:value-of select=
"$param.placement"/>
174 <xsl:call-template name=
"formal.object">
175 <xsl:with-param name=
"placement" select=
"$placement"/>
180 <xsl:template match=
"table">
182 <xsl:when test=
"tgroup|mediaobject|graphic">
183 <xsl:call-template name=
"calsTable"/>
187 <xsl:copy-of select=
"@*[not(local-name()='id')]"/>
188 <xsl:attribute name=
"id">
189 <xsl:call-template name=
"object.id"/>
191 <xsl:call-template name=
"htmlTable"/>
197 <xsl:template name=
"calsTable">
198 <xsl:if test=
"tgroup/tbody/tr
201 <xsl:message terminate=
"yes">Broken table: tr descendent of CALS Table.
</xsl:message>
204 <xsl:variable name=
"param.placement"
205 select=
"substring-after(normalize-space($formal.title.placement),
206 concat(local-name(.), ' '))"/>
208 <xsl:variable name=
"placement">
210 <xsl:when test=
"contains($param.placement, ' ')">
211 <xsl:value-of select=
"substring-before($param.placement, ' ')"/>
213 <xsl:when test=
"$param.placement = ''">before
</xsl:when>
215 <xsl:value-of select=
"$param.placement"/>
220 <xsl:call-template name=
"formal.object">
221 <xsl:with-param name=
"placement" select=
"$placement"/>
222 <xsl:with-param name=
"class">
224 <xsl:when test=
"@tabstyle">
225 <!-- hack, this will only ever occur on table, not example -->
226 <xsl:value-of select=
"@tabstyle"/>
229 <xsl:value-of select=
"local-name(.)"/>
236 <xsl:template name=
"htmlTable">
237 <xsl:if test=
"tgroup/tbody/row
240 <xsl:message terminate=
"yes">Broken table: row descendent of HTML table.
</xsl:message>
243 <xsl:apply-templates mode=
"htmlTable"/>
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">
253 <xsl:when test=
"contains($param.placement, ' ')">
254 <xsl:value-of select=
"substring-before($param.placement, ' ')"/>
256 <xsl:when test=
"$param.placement = ''">before
</xsl:when>
258 <xsl:value-of select=
"$param.placement"/>
263 <xsl:call-template name=
"formal.object">
264 <xsl:with-param name=
"placement" select=
"$placement"/>
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">
276 <xsl:when test=
"contains($param.placement, ' ')">
277 <xsl:value-of select=
"substring-before($param.placement, ' ')"/>
279 <xsl:when test=
"$param.placement = ''">before
</xsl:when>
281 <xsl:value-of select=
"$param.placement"/>
286 <xsl:call-template name=
"formal.object">
287 <xsl:with-param name=
"placement" select=
"$placement"/>
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"/>
306 <xsl:template match=
"informalexample">
307 <xsl:call-template name=
"informal.object"/>
310 <xsl:template match=
"informaltable">
312 <xsl:when test=
"tgroup|mediaobject|graphic">
313 <xsl:call-template name=
"informal.object">
314 <xsl:with-param name=
"class">
316 <xsl:when test=
"@tabstyle">
317 <xsl:value-of select=
"@tabstyle"/>
320 <xsl:value-of select=
"local-name(.)"/>
328 <xsl:copy-of select=
"@*"/>
329 <xsl:call-template name=
"htmlTable"/>
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=
"."/>
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=
"."/>
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"/>
361 <xsl:template match=
"informalequation">
362 <xsl:call-template name=
"informal.object"/>
365 <xsl:template name=
"floatstyle">
366 <xsl:if test=
"(@float and @float != '0') or @floatstyle != ''">
368 <xsl:when test=
"@floatstyle != ''">
369 <xsl:value-of select=
"@floatstyle"/>
371 <xsl:when test=
"@float = '1'">
372 <xsl:value-of select=
"$default.float.class"/>
375 <xsl:value-of select=
"@float"/>
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>
394 <xsl:copy-of select=
"$content"/>