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