]> git.lyx.org Git - lyx.git/blob - lib/docbook/xhtml/formal.xsl
Release notes
[lyx.git] / lib / docbook / xhtml / formal.xsl
1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="d" version="1.0">
2
3 <!-- ********************************************************************
4
5      This file is part of the XSL DocBook Stylesheet distribution.
6      See ../README or http://cdn.docbook.org/release/xsl/current/ for
7      copyright and other information.
8
9      ******************************************************************** -->
10
11 <xsl:param name="formal.object.break.after">1</xsl:param>
12
13 <xsl:template name="formal.object">
14   <xsl:param name="placement" select="'before'"/>
15   <xsl:param name="class">
16     <xsl:apply-templates select="." mode="class.value"/>
17   </xsl:param>
18
19   <xsl:call-template name="id.warning"/>
20
21   <xsl:variable name="content">
22     <div class="{$class}">
23       <xsl:call-template name="id.attribute">
24         <xsl:with-param name="conditional" select="0"/>
25       </xsl:call-template>
26       <xsl:call-template name="anchor">
27         <xsl:with-param name="conditional" select="0"/>
28       </xsl:call-template>
29     
30       <xsl:choose>
31         <xsl:when test="$placement = 'before'">
32           <xsl:call-template name="formal.object.heading"/>
33           <div class="{$class}-contents">
34             <xsl:apply-templates/>
35           </div>
36           <!-- HACK: This doesn't belong inside formal.object; it 
37                should be done by the table template, but I want 
38                the link to be inside the DIV, so... -->
39           <xsl:if test="local-name(.) = 'table'">
40             <xsl:call-template name="table.longdesc"/>
41           </xsl:if>
42     
43           <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
44         </xsl:when>
45         <xsl:otherwise>
46           <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
47           <div class="{$class}-contents"><xsl:apply-templates/></div>
48           <!-- HACK: This doesn't belong inside formal.object; it 
49                should be done by the table template, but I want 
50                the link to be inside the DIV, so... -->
51           <xsl:if test="local-name(.) = 'table'">
52             <xsl:call-template name="table.longdesc"/>
53           </xsl:if>
54     
55           <xsl:call-template name="formal.object.heading"/>
56         </xsl:otherwise>
57       </xsl:choose>
58     </div>
59     <xsl:if test="not($formal.object.break.after = '0')">
60       <br class="{$class}-break"/>
61     </xsl:if>
62   </xsl:variable>
63
64   <xsl:variable name="floatstyle">
65     <xsl:call-template name="floatstyle"/>
66   </xsl:variable>
67
68   <xsl:choose>
69     <xsl:when test="$floatstyle != ''">
70       <xsl:call-template name="floater">
71         <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
72         <xsl:with-param name="floatstyle" select="$floatstyle"/>
73         <xsl:with-param name="content" select="$content"/>
74       </xsl:call-template>
75     </xsl:when>
76     <xsl:otherwise>
77       <xsl:copy-of select="$content"/>
78     </xsl:otherwise>
79   </xsl:choose>
80
81 </xsl:template>
82
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>
89   </xsl:param>
90
91
92   <xsl:choose>
93     <xsl:when test="$make.clean.html != 0">
94       <xsl:variable name="html.class" select="concat(local-name($object),'-title')"/>
95       <div class="{$html.class}">
96         <xsl:copy-of select="$title"/>
97       </div>
98     </xsl:when>
99     <xsl:otherwise>
100       <p class="title">
101         <strong>
102           <xsl:copy-of select="$title"/>
103         </strong>
104       </p>
105     </xsl:otherwise>
106   </xsl:choose>
107 </xsl:template>
108
109 <xsl:template name="informal.object">
110   <xsl:param name="class">
111     <xsl:apply-templates select="." mode="class.value"/>
112   </xsl:param>
113
114   <xsl:variable name="content">
115     <div class="{$class}">
116       <xsl:call-template name="id.attribute"/>
117       <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
118       <xsl:call-template name="anchor"/>
119       <xsl:apply-templates/>
120   
121       <!-- HACK: This doesn't belong inside formal.object; it 
122            should be done by the table template, but I want 
123            the link to be inside the DIV, so... -->
124       <xsl:if test="local-name(.) = 'informaltable'">
125         <xsl:call-template name="table.longdesc"/>
126       </xsl:if>
127   
128       <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
129     </div>
130   </xsl:variable>
131
132   <xsl:variable name="floatstyle">
133     <xsl:call-template name="floatstyle"/>
134   </xsl:variable>
135
136   <xsl:choose>
137     <xsl:when test="$floatstyle != ''">
138       <xsl:call-template name="floater">
139         <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
140         <xsl:with-param name="floatstyle" select="$floatstyle"/>
141         <xsl:with-param name="content" select="$content"/>
142       </xsl:call-template>
143     </xsl:when>
144     <xsl:otherwise>
145       <xsl:copy-of select="$content"/>
146     </xsl:otherwise>
147   </xsl:choose>
148
149 </xsl:template>
150
151 <xsl:template name="semiformal.object">
152   <xsl:param name="placement" select="'before'"/>
153   <xsl:param name="class" select="local-name(.)"/>
154
155   <xsl:choose>
156     <xsl:when test="d:title or d:info/d:title">
157       <xsl:call-template name="formal.object">
158         <xsl:with-param name="placement" select="$placement"/>
159         <xsl:with-param name="class" select="$class"/>
160       </xsl:call-template>
161     </xsl:when>
162     <xsl:otherwise>
163       <xsl:call-template name="informal.object">
164         <xsl:with-param name="class" select="$class"/>
165       </xsl:call-template>
166     </xsl:otherwise>
167   </xsl:choose>
168 </xsl:template>
169
170 <xsl:template match="d:figure">
171   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                         concat(local-name(.), ' '))"/>
172
173   <xsl:variable name="placement">
174     <xsl:choose>
175       <xsl:when test="contains($param.placement, ' ')">
176         <xsl:value-of select="substring-before($param.placement, ' ')"/>
177       </xsl:when>
178       <xsl:when test="$param.placement = ''">before</xsl:when>
179       <xsl:otherwise>
180         <xsl:value-of select="$param.placement"/>
181       </xsl:otherwise>
182     </xsl:choose>
183   </xsl:variable>
184
185   <xsl:call-template name="formal.object">
186     <xsl:with-param name="placement" select="$placement"/>
187   </xsl:call-template>
188
189 </xsl:template>
190
191 <xsl:template match="d:table">
192   <xsl:choose>
193     <xsl:when test="d:tgroup|d:mediaobject|d:graphic">
194       <xsl:call-template name="calsTable"/>
195     </xsl:when>
196     <xsl:when test="d:caption">
197       <xsl:call-template name="htmlTable.with.caption"/>
198     </xsl:when>
199     <xsl:otherwise>
200       <!-- do not use xsl:copy because of XHTML's needs -->
201       <div>
202         <xsl:call-template name="generate.class.attribute"/>
203         <xsl:call-template name="id.attribute"/>
204         <xsl:call-template name="anchor"/>
205         <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
206           <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
207           <xsl:call-template name="htmlTable"/>
208         </xsl:element>
209       </div>
210     </xsl:otherwise>
211   </xsl:choose>
212 </xsl:template>
213
214 <!-- Handle html markup table like formal.object -->
215 <xsl:template name="htmlTable.with.caption">
216   <xsl:param name="class">
217     <xsl:apply-templates select="." mode="class.value"/>
218   </xsl:param>
219
220   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                         concat(local-name(.), ' '))"/>
221
222   <xsl:variable name="placement">
223     <xsl:choose>
224       <xsl:when test="contains($param.placement, ' ')">
225         <xsl:value-of select="substring-before($param.placement, ' ')"/>
226       </xsl:when>
227       <xsl:when test="$param.placement = ''">before</xsl:when>
228       <xsl:otherwise>
229         <xsl:value-of select="$param.placement"/>
230       </xsl:otherwise>
231     </xsl:choose>
232   </xsl:variable>
233
234   <xsl:call-template name="id.warning"/>
235
236   <xsl:variable name="content">
237     <div class="{$class}">
238       <xsl:call-template name="id.attribute">
239         <xsl:with-param name="conditional" select="0"/>
240       </xsl:call-template>
241       <xsl:call-template name="anchor">
242         <xsl:with-param name="conditional" select="0"/>
243       </xsl:call-template>
244     
245       <xsl:choose>
246         <xsl:when test="$placement = 'before'">
247
248           <xsl:call-template name="formal.object.heading"/>
249
250           <div class="{$class}-contents">
251             <xsl:apply-templates select="." mode="htmlTable"/>
252           </div>
253
254           <xsl:call-template name="table.longdesc"/>
255     
256           <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
257         </xsl:when>
258         <xsl:otherwise>
259           <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
260
261           <div class="{$class}-contents">
262             <xsl:apply-templates select="." mode="htmlTable"/>
263           </div>
264
265           <xsl:call-template name="table.longdesc"/>
266     
267           <xsl:call-template name="formal.object.heading"/>
268         </xsl:otherwise>
269       </xsl:choose>
270     </div>
271     <xsl:if test="not($formal.object.break.after = '0')">
272       <br class="{$class}-break"/>
273     </xsl:if>
274   </xsl:variable>
275
276   <xsl:variable name="floatstyle">
277     <xsl:call-template name="floatstyle"/>
278   </xsl:variable>
279
280   <xsl:choose>
281     <xsl:when test="$floatstyle != ''">
282       <xsl:call-template name="floater">
283         <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param>
284         <xsl:with-param name="floatstyle" select="$floatstyle"/>
285         <xsl:with-param name="content" select="$content"/>
286       </xsl:call-template>
287     </xsl:when>
288     <xsl:otherwise>
289       <xsl:copy-of select="$content"/>
290     </xsl:otherwise>
291   </xsl:choose>
292
293 </xsl:template>
294
295 <xsl:template name="calsTable">
296   <xsl:if test="d:tgroup/d:tbody/d:tr                 |d:tgroup/d:thead/d:tr                 |d:tgroup/d:tfoot/d:tr">
297     <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message>
298   </xsl:if>
299
300   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                         concat(local-name(.), ' '))"/>
301
302   <xsl:variable name="placement">
303     <xsl:choose>
304       <xsl:when test="contains($param.placement, ' ')">
305         <xsl:value-of select="substring-before($param.placement, ' ')"/>
306       </xsl:when>
307       <xsl:when test="$param.placement = ''">before</xsl:when>
308       <xsl:otherwise>
309         <xsl:value-of select="$param.placement"/>
310       </xsl:otherwise>
311     </xsl:choose>
312   </xsl:variable>
313
314   <xsl:call-template name="formal.object">
315     <xsl:with-param name="placement" select="$placement"/>
316   </xsl:call-template>
317 </xsl:template>
318
319 <xsl:template match="d:table|d:informaltable" mode="class.value">
320   <xsl:choose>
321     <xsl:when test="@tabstyle">
322       <xsl:value-of select="@tabstyle"/>
323     </xsl:when>
324     <xsl:otherwise>
325       <xsl:value-of select="local-name(.)"/>
326     </xsl:otherwise>
327   </xsl:choose>
328 </xsl:template>
329
330 <xsl:template name="htmlTable">
331   <xsl:if test="d:tgroup/d:tbody/d:row                 |d:tgroup/d:thead/d:row                 |d:tgroup/d:tfoot/d:row">
332     <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message>
333   </xsl:if>
334
335   <xsl:apply-templates mode="htmlTable"/>
336
337   <xsl:if test=".//d:footnote|../d:title//d:footnote">
338     <tbody class="footnotes">
339       <tr>
340         <td colspan="50">
341           <xsl:apply-templates select=".//d:footnote|../d:title//d:footnote" mode="table.footnote.mode"/>
342         </td>
343       </tr>
344     </tbody>
345   </xsl:if>
346 </xsl:template>
347
348 <xsl:template match="d:example">
349   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                      concat(local-name(.), ' '))"/>
350
351   <xsl:variable name="placement">
352     <xsl:choose>
353       <xsl:when test="contains($param.placement, ' ')">
354         <xsl:value-of select="substring-before($param.placement, ' ')"/>
355       </xsl:when>
356       <xsl:when test="$param.placement = ''">before</xsl:when>
357       <xsl:otherwise>
358         <xsl:value-of select="$param.placement"/>
359       </xsl:otherwise>
360     </xsl:choose>
361   </xsl:variable>
362
363   <xsl:call-template name="formal.object">
364     <xsl:with-param name="placement" select="$placement"/>
365   </xsl:call-template>
366
367 </xsl:template>
368
369 <xsl:template match="d:equation">
370   <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),                                       concat(local-name(.), ' '))"/>
371
372   <xsl:variable name="placement">
373     <xsl:choose>
374       <xsl:when test="contains($param.placement, ' ')">
375         <xsl:value-of select="substring-before($param.placement, ' ')"/>
376       </xsl:when>
377       <xsl:when test="$param.placement = ''">before</xsl:when>
378       <xsl:otherwise>
379         <xsl:value-of select="$param.placement"/>
380       </xsl:otherwise>
381     </xsl:choose>
382   </xsl:variable>
383
384   <xsl:call-template name="formal.object">
385     <xsl:with-param name="placement" select="$placement"/>
386   </xsl:call-template>
387
388 </xsl:template>
389
390 <xsl:template match="d:figure/d:title"/>
391 <xsl:template match="d:figure/d:titleabbrev"/>
392 <xsl:template match="d:table/d:title"/>
393 <xsl:template match="d:table/d:titleabbrev"/>
394 <xsl:template match="d:table/d:textobject"/>
395 <xsl:template match="d:example/d:title"/>
396 <xsl:template match="d:example/d:titleabbrev"/>
397 <xsl:template match="d:equation/d:title"/>
398 <xsl:template match="d:equation/d:titleabbrev"/>
399
400 <xsl:template match="d:informalfigure">
401   <xsl:call-template name="informal.object"/>
402 </xsl:template>
403
404 <xsl:template match="d:informalexample">
405   <xsl:call-template name="informal.object"/>
406 </xsl:template>
407
408 <xsl:template match="d:informaltable">
409   <xsl:choose>
410     <xsl:when test="d:tgroup|d:mediaobject|d:graphic">
411       <xsl:call-template name="informal.object"/>
412     </xsl:when>
413     <xsl:otherwise>
414       <div>
415         <xsl:call-template name="generate.class.attribute"/>
416         <xsl:call-template name="id.attribute"/>
417         <xsl:call-template name="anchor"/>
418         <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
419           <xsl:apply-templates select="@*" mode="htmlTableAtt"/>
420           <xsl:call-template name="htmlTable"/>
421         </xsl:element>
422       </div>
423     </xsl:otherwise>
424   </xsl:choose>
425 </xsl:template>
426
427 <xsl:template match="d:informaltable/d:textobject"/>
428
429 <xsl:template name="table.longdesc">
430   <!-- HACK: This doesn't belong inside formal.objectt; it should be done by -->
431   <!-- the table template, but I want the link to be inside the DIV, so... -->
432   <xsl:variable name="longdesc.uri">
433     <xsl:call-template name="longdesc.uri">
434       <xsl:with-param name="mediaobject" select="."/>
435     </xsl:call-template>
436   </xsl:variable>
437
438   <xsl:variable name="irrelevant">
439     <!-- write.longdesc returns the filename ... -->
440     <xsl:call-template name="write.longdesc">
441       <xsl:with-param name="mediaobject" select="."/>
442     </xsl:call-template>
443   </xsl:variable>
444
445   <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0                 and d:textobject[not(d:phrase)]">
446     <xsl:call-template name="longdesc.link">
447       <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/>
448     </xsl:call-template>
449   </xsl:if>
450 </xsl:template>
451
452 <xsl:template match="d:informalequation">
453   <xsl:call-template name="informal.object"/>
454 </xsl:template>
455
456 <xsl:template name="floatstyle">
457   <xsl:if test="(@float and @float != '0') or @floatstyle != ''">
458     <xsl:choose>
459       <xsl:when test="@floatstyle != ''">
460         <xsl:value-of select="@floatstyle"/>
461       </xsl:when>
462       <xsl:when test="@float = '1'">
463         <xsl:value-of select="$default.float.class"/>
464       </xsl:when>
465       <xsl:otherwise>
466         <xsl:value-of select="@float"/>
467       </xsl:otherwise>
468     </xsl:choose>
469   </xsl:if>
470 </xsl:template>
471
472 <xsl:template name="floater">
473   <xsl:param name="content"/>
474   <xsl:param name="class" select="'float'"/>
475   <xsl:param name="floatstyle" select="'left'"/>
476
477   <div class="{$class}">
478     <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'">
479       <xsl:attribute name="style">
480         <xsl:text>float: </xsl:text>
481         <xsl:value-of select="$floatstyle"/>
482         <xsl:text>;</xsl:text>
483       </xsl:attribute>
484     </xsl:if>
485     <xsl:copy-of select="$content"/>
486   </div>
487 </xsl:template>
488
489 </xsl:stylesheet>