]> git.stg.codes - stg.git/blob - doc/xslt/html/block.xsl
Set output encoding to utf-8.
[stg.git] / doc / xslt / html / block.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 version='1.0'>
4
5 <!-- ********************************************************************
6      $Id: block.xsl 8831 2010-08-13 17:08:49Z mzjn $
7      ********************************************************************
8
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.
12
13      ******************************************************************** -->
14
15 <!-- ==================================================================== -->
16 <!-- What should we do about styling blockinfo? -->
17
18 <xsl:template match="blockinfo|info">
19   <!-- suppress -->
20 </xsl:template>
21
22 <!-- ==================================================================== -->
23
24 <xsl:template name="block.object">
25   <div>
26     <xsl:call-template name="common.html.attributes"/>
27     <xsl:call-template name="anchor"/>
28     <xsl:apply-templates/>
29   </div>
30 </xsl:template>
31
32 <!-- ==================================================================== -->
33
34 <xsl:template match="para">
35   <xsl:call-template name="paragraph">
36     <xsl:with-param name="class">
37       <xsl:if test="@role and $para.propagates.style != 0">
38         <xsl:value-of select="@role"/>
39       </xsl:if>
40     </xsl:with-param>
41     <xsl:with-param name="content">
42       <xsl:if test="position() = 1 and parent::listitem">
43         <xsl:call-template name="anchor">
44           <xsl:with-param name="node" select="parent::listitem"/>
45         </xsl:call-template>
46       </xsl:if>
47
48       <xsl:call-template name="anchor"/>
49       <xsl:apply-templates/>
50     </xsl:with-param>
51   </xsl:call-template>
52 </xsl:template>
53
54 <xsl:template name="paragraph">
55   <xsl:param name="class" select="''"/>
56   <xsl:param name="content"/>
57
58   <xsl:variable name="p">
59     <p>
60       <xsl:choose>
61         <xsl:when test="$class != ''">
62           <xsl:call-template name="common.html.attributes">
63             <xsl:with-param name="class" select="$class"/>
64           </xsl:call-template>
65         </xsl:when>
66         <xsl:otherwise>
67           <xsl:call-template name="locale.html.attributes"/>
68         </xsl:otherwise>
69       </xsl:choose>
70       <xsl:copy-of select="$content"/>
71     </p>
72   </xsl:variable>
73
74   <xsl:choose>
75     <xsl:when test="$html.cleanup != 0">
76       <xsl:call-template name="unwrap.p">
77         <xsl:with-param name="p" select="$p"/>
78       </xsl:call-template>
79     </xsl:when>
80     <xsl:otherwise>
81       <xsl:copy-of select="$p"/>
82     </xsl:otherwise>
83   </xsl:choose>
84 </xsl:template>
85
86 <xsl:template match="simpara">
87   <!-- see also listitem/simpara in lists.xsl -->
88   <p>
89     <xsl:call-template name="locale.html.attributes"/>
90     <xsl:if test="@role and $para.propagates.style != 0">
91       <xsl:apply-templates select="." mode="class.attribute">
92         <xsl:with-param name="class" select="@role"/>
93       </xsl:apply-templates>
94     </xsl:if>
95
96     <xsl:call-template name="anchor"/>
97     <xsl:apply-templates/>
98   </p>
99 </xsl:template>
100
101 <xsl:template match="formalpara">
102   <xsl:call-template name="paragraph">
103     <xsl:with-param name="class">
104       <xsl:if test="@role and $para.propagates.style != 0">
105         <xsl:value-of select="@role"/>
106       </xsl:if>
107     </xsl:with-param>
108     <xsl:with-param name="content">
109       <xsl:call-template name="anchor"/>
110       <xsl:apply-templates/>
111     </xsl:with-param>
112   </xsl:call-template>
113 </xsl:template>
114
115 <!-- Only use title from info -->
116 <xsl:template match="formalpara/info">
117   <xsl:apply-templates select="title"/>
118 </xsl:template>
119
120 <xsl:template match="formalpara/title|formalpara/info/title">
121   <xsl:variable name="titleStr">
122       <xsl:apply-templates/>
123   </xsl:variable>
124   <xsl:variable name="lastChar">
125     <xsl:if test="$titleStr != ''">
126       <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/>
127     </xsl:if>
128   </xsl:variable>
129
130   <xsl:choose>
131     <xsl:when test="$make.clean.html != 0">
132       <span class="formalpara-title">
133         <xsl:copy-of select="$titleStr"/>
134         <xsl:if test="$lastChar != ''
135                       and not(contains($runinhead.title.end.punct, $lastChar))">
136           <xsl:value-of select="$runinhead.default.title.end.punct"/>
137         </xsl:if>
138         <xsl:text>&#160;</xsl:text>
139       </span>
140     </xsl:when>
141     <xsl:otherwise>
142       <b>
143         <xsl:copy-of select="$titleStr"/>
144         <xsl:if test="$lastChar != ''
145                       and not(contains($runinhead.title.end.punct, $lastChar))">
146           <xsl:value-of select="$runinhead.default.title.end.punct"/>
147         </xsl:if>
148         <xsl:text>&#160;</xsl:text>
149       </b>
150     </xsl:otherwise>
151   </xsl:choose>
152 </xsl:template>
153
154 <xsl:template match="formalpara/para">
155   <xsl:apply-templates/>
156 </xsl:template>
157
158 <!-- ==================================================================== -->
159
160 <xsl:template match="blockquote">
161   <div>
162     <xsl:call-template name="common.html.attributes"/>
163     <xsl:call-template name="anchor"/>
164
165     <xsl:choose>
166       <xsl:when test="attribution">
167         <table border="0" width="100%"
168                cellspacing="0" cellpadding="0" class="blockquote"
169                summary="Block quote">
170           <tr>
171             <td width="10%" valign="top">&#160;</td>
172             <td width="80%" valign="top">
173               <xsl:apply-templates select="child::*[local-name(.)!='attribution']"/>
174             </td>
175             <td width="10%" valign="top">&#160;</td>
176           </tr>
177           <tr>
178             <td width="10%" valign="top">&#160;</td>
179             <td colspan="2" align="{$direction.align.end}" valign="top">
180               <xsl:text>--</xsl:text>
181               <xsl:apply-templates select="attribution"/>
182             </td>
183           </tr>
184         </table>
185       </xsl:when>
186       <xsl:otherwise>
187         <blockquote>
188           <xsl:call-template name="common.html.attributes"/>
189           <xsl:apply-templates/>
190         </blockquote>
191       </xsl:otherwise>
192     </xsl:choose>
193   </div>
194 </xsl:template>
195
196 <xsl:template match="blockquote/title|blockquote/info/title">
197   <xsl:choose>
198     <xsl:when test="$make.clean.html != 0">
199       <div class="blockquote-title">
200         <xsl:apply-templates/>
201       </div>
202     </xsl:when>
203     <xsl:otherwise>
204       <div class="blockquote-title">
205         <p>
206           <b>
207             <xsl:apply-templates/>
208           </b>
209         </p>
210       </div>
211     </xsl:otherwise>
212   </xsl:choose>
213 </xsl:template>
214
215 <!-- Use an em dash per Chicago Manual of Style and https://sourceforge.net/tracker/index.php?func=detail&aid=2793878&group_id=21935&atid=373747 -->
216 <xsl:template match="epigraph">
217   <div>
218     <xsl:call-template name="common.html.attributes"/>
219       <xsl:apply-templates select="para|simpara|formalpara|literallayout"/>
220       <xsl:if test="attribution">
221         <div class="attribution">
222           <span>&#x2014;<xsl:apply-templates select="attribution"/></span>
223         </div>
224       </xsl:if>
225   </div>
226 </xsl:template>
227
228 <xsl:template match="attribution">
229   <span>
230     <xsl:call-template name="common.html.attributes"/>
231     <xsl:apply-templates/>
232   </span>
233 </xsl:template>
234
235 <!-- ==================================================================== -->
236
237 <xsl:template match="abstract|sidebar">
238   <div>
239     <xsl:call-template name="common.html.attributes"/>
240     <xsl:call-template name="anchor"/>
241     <xsl:call-template name="sidebar.titlepage"/>
242     <xsl:apply-templates/>
243   </div>
244 </xsl:template>
245
246 <xsl:template match="abstract/title|sidebar/title">
247 </xsl:template>
248
249 <xsl:template match="sidebar/sidebarinfo|sidebar/info"/>
250
251 <!-- ==================================================================== -->
252
253 <xsl:template match="msgset">
254   <xsl:apply-templates/>
255 </xsl:template>
256
257 <xsl:template match="msgentry">
258   <xsl:call-template name="block.object"/>
259 </xsl:template>
260
261 <xsl:template match="simplemsgentry">
262   <xsl:call-template name="block.object"/>
263 </xsl:template>
264
265 <xsl:template match="msg">
266   <xsl:call-template name="block.object"/>
267 </xsl:template>
268
269 <xsl:template match="msgmain">
270   <xsl:apply-templates/>
271 </xsl:template>
272
273 <xsl:template match="msgmain/title">
274   <xsl:choose>
275     <xsl:when test="$make.clean.html != 0">
276       <span class="msgmain-title">
277         <xsl:apply-templates/>
278       </span>
279     </xsl:when>
280     <xsl:otherwise>
281       <b><xsl:apply-templates/></b>
282     </xsl:otherwise>
283   </xsl:choose>
284 </xsl:template>
285
286 <xsl:template match="msgsub">
287   <xsl:apply-templates/>
288 </xsl:template>
289
290 <xsl:template match="msgsub/title">
291   <xsl:choose>
292     <xsl:when test="$make.clean.html != 0">
293       <span class="msgsub-title">
294         <xsl:apply-templates/>
295       </span>
296     </xsl:when>
297     <xsl:otherwise>
298       <b><xsl:apply-templates/></b>
299     </xsl:otherwise>
300   </xsl:choose>
301 </xsl:template>
302
303 <xsl:template match="msgrel">
304   <xsl:apply-templates/>
305 </xsl:template>
306
307 <xsl:template match="msgrel/title">
308   <xsl:choose>
309     <xsl:when test="$make.clean.html != 0">
310       <span class="msgrel-title">
311         <xsl:apply-templates/>
312       </span>
313     </xsl:when>
314     <xsl:otherwise>
315       <b><xsl:apply-templates/></b>
316     </xsl:otherwise>
317   </xsl:choose>
318 </xsl:template>
319
320 <xsl:template match="msgtext">
321   <xsl:apply-templates/>
322 </xsl:template>
323
324 <xsl:template match="msginfo">
325   <xsl:call-template name="block.object"/>
326 </xsl:template>
327
328 <xsl:template match="msglevel">
329   <xsl:choose>
330     <xsl:when test="$make.clean.html != 0">
331       <div class="msglevel">
332         <span class="msglevel-title">
333           <xsl:call-template name="gentext.template">
334             <xsl:with-param name="context" select="'msgset'"/>
335             <xsl:with-param name="name" select="'MsgLevel'"/>
336           </xsl:call-template>
337         </span>
338         <xsl:apply-templates/>
339       </div>
340     </xsl:when>
341     <xsl:otherwise>
342       <p>
343         <b>
344           <xsl:call-template name="gentext.template">
345             <xsl:with-param name="context" select="'msgset'"/>
346             <xsl:with-param name="name" select="'MsgLevel'"/>
347           </xsl:call-template>
348         </b>
349         <xsl:apply-templates/>
350       </p>
351     </xsl:otherwise>
352   </xsl:choose>
353 </xsl:template>
354
355 <xsl:template match="msgorig">
356   <xsl:choose>
357     <xsl:when test="$make.clean.html != 0">
358       <div class="msgorig">
359         <span class="msgorig-title">
360           <xsl:call-template name="gentext.template">
361             <xsl:with-param name="context" select="'msgset'"/>
362             <xsl:with-param name="name" select="'MsgOrig'"/>
363           </xsl:call-template>
364         </span>
365         <xsl:apply-templates/>
366       </div>
367     </xsl:when>
368     <xsl:otherwise>
369       <p>
370         <b>
371           <xsl:call-template name="gentext.template">
372             <xsl:with-param name="context" select="'msgset'"/>
373             <xsl:with-param name="name" select="'MsgOrig'"/>
374           </xsl:call-template>
375         </b>
376         <xsl:apply-templates/>
377       </p>
378     </xsl:otherwise>
379   </xsl:choose>
380 </xsl:template>
381
382 <xsl:template match="msgaud">
383   <xsl:choose>
384     <xsl:when test="$make.clean.html != 0">
385       <div class="msgaud">
386         <span class="msgaud-title">
387           <xsl:call-template name="gentext.template">
388             <xsl:with-param name="context" select="'msgset'"/>
389             <xsl:with-param name="name" select="'MsgAud'"/>
390           </xsl:call-template>
391         </span>
392         <xsl:apply-templates/>
393       </div>
394     </xsl:when>
395     <xsl:otherwise>
396       <p>
397         <b>
398           <xsl:call-template name="gentext.template">
399             <xsl:with-param name="context" select="'msgset'"/>
400             <xsl:with-param name="name" select="'MsgAud'"/>
401           </xsl:call-template>
402         </b>
403         <xsl:apply-templates/>
404       </p>
405     </xsl:otherwise>
406   </xsl:choose>
407 </xsl:template>
408
409 <xsl:template match="msgexplan">
410   <xsl:call-template name="block.object"/>
411 </xsl:template>
412
413 <xsl:template match="msgexplan/title">
414   <xsl:choose>
415     <xsl:when test="$make.clean.html != 0">
416       <div class="msgexplan">
417         <span class="msgexplan-title">
418           <xsl:apply-templates/>
419         </span>
420       </div>
421     </xsl:when>
422     <xsl:otherwise>
423       <p>
424         <b>
425           <xsl:apply-templates/>
426         </b>
427       </p>
428     </xsl:otherwise>
429   </xsl:choose>
430 </xsl:template>
431
432 <!-- ==================================================================== -->
433
434 <xsl:template match="revhistory">
435   <div>
436     <xsl:call-template name="common.html.attributes"/>
437     <table border="0" width="100%" summary="Revision history">
438       <tr>
439         <th align="{$direction.align.start}" valign="top" colspan="3">
440           <b>
441             <xsl:call-template name="gentext">
442               <xsl:with-param name="key" select="'RevHistory'"/>
443             </xsl:call-template>
444           </b>
445         </th>
446       </tr>
447       <xsl:apply-templates/>
448     </table>
449   </div>
450 </xsl:template>
451
452 <xsl:template match="revhistory/revision">
453   <xsl:variable name="revnumber" select="revnumber"/>
454   <xsl:variable name="revdate"   select="date"/>
455   <xsl:variable name="revauthor" select="authorinitials|author"/>
456   <xsl:variable name="revremark" select="revremark|revdescription"/>
457   <tr>
458     <td align="{$direction.align.start}">
459       <xsl:if test="$revnumber">
460         <xsl:call-template name="gentext">
461           <xsl:with-param name="key" select="'Revision'"/>
462         </xsl:call-template>
463         <xsl:call-template name="gentext.space"/>
464         <xsl:apply-templates select="$revnumber"/>
465       </xsl:if>
466     </td>
467     <td align="{$direction.align.start}">
468       <xsl:apply-templates select="$revdate"/>
469     </td>
470     <xsl:choose>
471       <xsl:when test="count($revauthor)=0">
472         <td align="{$direction.align.start}">
473           <xsl:call-template name="dingbat">
474             <xsl:with-param name="dingbat">nbsp</xsl:with-param>
475           </xsl:call-template>
476         </td>
477       </xsl:when>
478       <xsl:otherwise>
479         <td align="{$direction.align.start}">
480           <xsl:for-each select="$revauthor">
481             <xsl:apply-templates select="."/>
482             <xsl:if test="position() != last()">
483               <xsl:text>, </xsl:text>
484             </xsl:if>
485           </xsl:for-each>
486         </td>
487       </xsl:otherwise>
488     </xsl:choose>
489   </tr>
490   <xsl:if test="$revremark">
491     <tr>
492       <td align="{$direction.align.start}" colspan="3">
493         <xsl:apply-templates select="$revremark"/>
494       </td>
495     </tr>
496   </xsl:if>
497 </xsl:template>
498
499 <xsl:template match="revision/revnumber">
500   <xsl:apply-templates/>
501 </xsl:template>
502
503 <xsl:template match="revision/date">
504   <xsl:apply-templates/>
505 </xsl:template>
506
507 <xsl:template match="revision/authorinitials">
508   <xsl:text>, </xsl:text>
509   <xsl:apply-templates/>
510 </xsl:template>
511
512 <xsl:template match="revision/authorinitials[1]" priority="2">
513   <xsl:apply-templates/>
514 </xsl:template>
515
516 <xsl:template match="revision/revremark">
517   <xsl:apply-templates/>
518 </xsl:template>
519
520 <xsl:template match="revision/revdescription">
521   <xsl:apply-templates/>
522 </xsl:template>
523
524 <!-- ==================================================================== -->
525
526 <xsl:template match="ackno|acknowledgements[parent::article]">
527   <xsl:call-template name="block.object"/>
528 </xsl:template>
529
530 <!-- ==================================================================== -->
531
532 <xsl:template match="highlights">
533   <xsl:call-template name="block.object"/>
534 </xsl:template>
535
536 <!-- ==================================================================== -->
537
538 </xsl:stylesheet>