]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/xhtml/formal.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / xhtml / formal.xsl
1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
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: formal.xsl 8310 2009-03-11 08:29:45Z bobstayton $
8      ********************************************************************
9
10      This file is part of the XSL DocBook Stylesheet distribution.
11      See ../README or http://docbook.sf.net/release/xsl/current/ for
12      copyright and other information.
13
14      ******************************************************************** -->
15
16 <xsl:param name="formal.object.break.after">1</xsl:param>
17
18 <xsl:template name="formal.object">
19   <xsl:param name="placement" select="'before'"/>
20   <xsl:param name="class">
21     <xsl:apply-templates select="." mode="class.value"/>
22   </xsl:param>
23
24   <xsl:call-template name="id.warning"/>
25
26   <xsl:variable name="content">
27     <div class="{$class}">
28       <xsl:call-template name="anchor">
29         <xsl:with-param name="conditional" select="0"/>
30       </xsl:call-template>
31     
32       <xsl:choose>
33         <xsl:when test="$placement = 'before'">
34           <xsl:call-template name="formal.object.heading"/>
35           <div class="{$class}-contents">
36             <xsl:apply-templates/>
37           </div>
38           <!-- HACK: This doesn't belong inside formal.object; it 
39                should be done by the table template, but I want 
40                the link to be inside the DIV, so... -->
41           <xsl:if test="local-name(.) = 'table'">
42             <xsl:call-template name="table.longdesc"/>
43           </xsl:if>
44     
45           <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
46         </xsl:when>
47         <xsl:otherwise>
48           <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
49           <div class="{$class}-contents"><xsl:apply-templates/></div>
50           <!-- HACK: This doesn't belong inside formal.object; it 
51                should be done by the table template, but I want 
52                the link to be inside the DIV, so... -->
53           <xsl:if test="local-name(.) = 'table'">
54             <xsl:call-template name="table.longdesc"/>
55           </xsl:if>
56     
57           <xsl:call-template name="formal.object.heading"/>
58         </xsl:otherwise>
59       </xsl:choose>
60     </div>
61     <xsl:if test="not($formal.object.break.after = '0')">
62       <br class="{$class}-break"/>
63     </xsl:if>
64   </xsl:variable>
65
66   <xsl:variable name="floatstyle">
67     <xsl:call-template name="floatstyle"/>
68   </xsl:variable>
69
70   <xsl:choose>
71     <xsl:when test="$floatstyle != ''">
72       <xsl:call-template name="floater">
73         <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
74         <xsl:with-param name="floatstyle" select="$floatstyle"/>
75         <xsl:with-param name="content" select="$content"/>
76       </xsl:call-template>
77     </xsl:when>
78     <xsl:otherwise>
79       <xsl:copy-of select="$content"/>
80     </xsl:otherwise>
81   </xsl:choose>
82
83 </xsl:template>
84
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>
91   </xsl:param>
92
93   <p class="title">
94     <b>
95       <xsl:copy-of select="$title"/>
96     </b>
97   </p>
98 </xsl:template>
99
100 <xsl:template name="informal.object">
101   <xsl:param name="class" select="local-name(.)"/>
102
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/>
108   
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"/>
114       </xsl:if>
115   
116       <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
117     </div>
118   </xsl:variable>
119
120   <xsl:variable name="floatstyle">
121     <xsl:call-template name="floatstyle"/>
122   </xsl:variable>
123
124   <xsl:choose>
125     <xsl:when test="$floatstyle != ''">
126       <xsl:call-template name="floater">
127         <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
128         <xsl:with-param name="floatstyle" select="$floatstyle"/>
129         <xsl:with-param name="content" select="$content"/>
130       </xsl:call-template>
131     </xsl:when>
132     <xsl:otherwise>
133       <xsl:copy-of select="$content"/>
134     </xsl:otherwise>
135   </xsl:choose>
136
137 </xsl:template>
138
139 <xsl:template name="semiformal.object">
140   <xsl:param name="placement" select="'before'"/>
141   <xsl:param name="class" select="local-name(.)"/>
142
143   <xsl:choose>
144     <xsl:when test="title">
145       <xsl:call-template name="formal.object">
146         <xsl:with-param name="placement" select="$placement"/>
147         <xsl:with-param name="class" select="$class"/>
148       </xsl:call-template>
149     </xsl:when>
150     <xsl:otherwise>
151       <xsl:call-template name="informal.object">
152         <xsl:with-param name="class" select="$class"/>
153       </xsl:call-template>
154     </xsl:otherwise>
155   </xsl:choose>
156 </xsl:template>
157
158 <xsl:template match="figure">
159   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                         concat(local-name(.), ' '))"/>
160
161   <xsl:variable name="placement">
162     <xsl:choose>
163       <xsl:when test="contains($param.placement, ' ')">
164         <xsl:value-of select="substring-before($param.placement, ' ')"/>
165       </xsl:when>
166       <xsl:when test="$param.placement = ''">before</xsl:when>
167       <xsl:otherwise>
168         <xsl:value-of select="$param.placement"/>
169       </xsl:otherwise>
170     </xsl:choose>
171   </xsl:variable>
172
173   <xsl:call-template name="formal.object">
174     <xsl:with-param name="placement" select="$placement"/>
175   </xsl:call-template>
176
177 </xsl:template>
178
179 <xsl:template match="table">
180   <xsl:choose>
181     <xsl:when test="tgroup|mediaobject|graphic">
182       <xsl:call-template name="calsTable"/>
183     </xsl:when>
184     <xsl:otherwise>
185       <!-- do not use xsl:copy because of XHTML's needs -->
186       <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
187         <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
188         <xsl:attribute name="id">
189           <xsl:call-template name="object.id"/>
190         </xsl:attribute>
191         <xsl:call-template name="htmlTable"/>
192       </xsl:element>
193     </xsl:otherwise>
194   </xsl:choose>
195 </xsl:template>
196
197 <xsl:template name="calsTable">
198   <xsl:if test="tgroup/tbody/tr                 |tgroup/thead/tr                 |tgroup/tfoot/tr">
199     <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
200   </xsl:if>
201
202   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                         concat(local-name(.), ' '))"/>
203
204   <xsl:variable name="placement">
205     <xsl:choose>
206       <xsl:when test="contains($param.placement, ' ')">
207         <xsl:value-of select="substring-before($param.placement, ' ')"/>
208       </xsl:when>
209       <xsl:when test="$param.placement = ''">before</xsl:when>
210       <xsl:otherwise>
211         <xsl:value-of select="$param.placement"/>
212       </xsl:otherwise>
213     </xsl:choose>
214   </xsl:variable>
215
216   <xsl:call-template name="formal.object">
217     <xsl:with-param name="placement" select="$placement"/>
218     <xsl:with-param name="class">
219       <xsl:choose>
220         <xsl:when test="@tabstyle">
221           <!-- hack, this will only ever occur on table, not example -->
222           <xsl:value-of select="@tabstyle"/>
223         </xsl:when>
224         <xsl:otherwise>
225           <xsl:value-of select="local-name(.)"/>
226         </xsl:otherwise>
227       </xsl:choose>
228     </xsl:with-param>
229   </xsl:call-template>
230 </xsl:template>
231
232 <xsl:template name="htmlTable">
233   <xsl:if test="tgroup/tbody/row                 |tgroup/thead/row                 |tgroup/tfoot/row">
234     <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
235   </xsl:if>
236
237   <xsl:apply-templates mode="htmlTable"/>
238 </xsl:template>
239
240 <xsl:template match="example">
241   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                      concat(local-name(.), ' '))"/>
242
243   <xsl:variable name="placement">
244     <xsl:choose>
245       <xsl:when test="contains($param.placement, ' ')">
246         <xsl:value-of select="substring-before($param.placement, ' ')"/>
247       </xsl:when>
248       <xsl:when test="$param.placement = ''">before</xsl:when>
249       <xsl:otherwise>
250         <xsl:value-of select="$param.placement"/>
251       </xsl:otherwise>
252     </xsl:choose>
253   </xsl:variable>
254
255   <xsl:call-template name="formal.object">
256     <xsl:with-param name="placement" select="$placement"/>
257   </xsl:call-template>
258
259 </xsl:template>
260
261 <xsl:template match="equation">
262   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                       concat(local-name(.), ' '))"/>
263
264   <xsl:variable name="placement">
265     <xsl:choose>
266       <xsl:when test="contains($param.placement, ' ')">
267         <xsl:value-of select="substring-before($param.placement, ' ')"/>
268       </xsl:when>
269       <xsl:when test="$param.placement = ''">before</xsl:when>
270       <xsl:otherwise>
271         <xsl:value-of select="$param.placement"/>
272       </xsl:otherwise>
273     </xsl:choose>
274   </xsl:variable>
275
276   <xsl:call-template name="formal.object">
277     <xsl:with-param name="placement" select="$placement"/>
278   </xsl:call-template>
279
280 </xsl:template>
281
282 <xsl:template match="figure/title"/>
283 <xsl:template match="figure/titleabbrev"/>
284 <xsl:template match="table/title"/>
285 <xsl:template match="table/titleabbrev"/>
286 <xsl:template match="table/textobject"/>
287 <xsl:template match="example/title"/>
288 <xsl:template match="example/titleabbrev"/>
289 <xsl:template match="equation/title"/>
290 <xsl:template match="equation/titleabbrev"/>
291
292 <xsl:template match="informalfigure">
293   <xsl:call-template name="informal.object"/>
294 </xsl:template>
295
296 <xsl:template match="informalexample">
297   <xsl:call-template name="informal.object"/>
298 </xsl:template>
299
300 <xsl:template match="informaltable">
301   <xsl:choose>
302     <xsl:when test="tgroup|mediaobject|graphic">
303       <xsl:call-template name="informal.object">
304         <xsl:with-param name="class">
305           <xsl:choose>
306             <xsl:when test="@tabstyle">
307               <xsl:value-of select="@tabstyle"/>
308             </xsl:when>
309             <xsl:otherwise>
310               <xsl:value-of select="local-name(.)"/>
311             </xsl:otherwise>
312           </xsl:choose>
313         </xsl:with-param>
314       </xsl:call-template>
315     </xsl:when>
316     <xsl:otherwise>
317       <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
318         <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
319         <xsl:attribute name="id">
320           <xsl:call-template name="object.id"/>
321         </xsl:attribute>
322         <xsl:call-template name="htmlTable"/>
323       </xsl:element>
324     </xsl:otherwise>
325   </xsl:choose>
326 </xsl:template>
327
328 <xsl:template match="informaltable/textobject"/>
329
330 <xsl:template name="table.longdesc">
331   <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
332   <!-- the table template, but I want the link to be inside the DIV, so... -->
333   <xsl:variable name="longdesc.uri">
334     <xsl:call-template name="longdesc.uri">
335       <xsl:with-param name="mediaobject" select="."/>
336     </xsl:call-template>
337   </xsl:variable>
338
339   <xsl:variable name="irrelevant">
340     <!-- write.longdesc returns the filename ... -->
341     <xsl:call-template name="write.longdesc">
342       <xsl:with-param name="mediaobject" select="."/>
343     </xsl:call-template>
344   </xsl:variable>
345
346   <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0                 and textobject[not(phrase)]">
347     <xsl:call-template name="longdesc.link">
348       <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
349     </xsl:call-template>
350   </xsl:if>
351 </xsl:template>
352
353 <xsl:template match="informalequation">
354   <xsl:call-template name="informal.object"/>
355 </xsl:template>
356
357 <xsl:template name="floatstyle">
358   <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
359     <xsl:choose>
360       <xsl:when test="@floatstyle != ''">
361         <xsl:value-of select="@floatstyle"/>
362       </xsl:when>
363       <xsl:when test="@float = '1'">
364         <xsl:value-of select="$default.float.class"/>
365       </xsl:when>
366       <xsl:otherwise>
367         <xsl:value-of select="@float"/>
368       </xsl:otherwise>
369     </xsl:choose>
370   </xsl:if>
371 </xsl:template>
372
373 <xsl:template name="floater">
374   <xsl:param name="content"/>
375   <xsl:param name="class" select="'float'"/>
376   <xsl:param name="floatstyle" select="'left'"/>
377
378   <div class="{$class}">
379     <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
380       <xsl:attribute name="style">
381         <xsl:text>float: </xsl:text>
382         <xsl:value-of select="$floatstyle"/>
383         <xsl:text>;</xsl:text>
384       </xsl:attribute>
385     </xsl:if>
386     <xsl:copy-of select="$content"/>
387   </div>
388 </xsl:template>
389
390 </xsl:stylesheet>