~ubuntu-branches/ubuntu/vivid/installation-guide/vivid-proposed

« back to all changes in this revision

Viewing changes to build/stylesheets/db2latex/admonition.mod.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Frans Pop
  • Date: 2005-10-25 17:37:25 UTC
  • Revision ID: james.westby@ubuntu.com-20051025173725-aq0bm11be7bfd7rw
Tags: 20051025
* Mention in copyright that full GPL is included in the manual.
  Closes: #334925
* Register installed documents with doc-base.
* Minor updates in English text and translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0'?>
 
2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
 
3
<!--############################################################################# 
 
4
|       $Id: admonition.mod.xsl,v 1.15 2004/08/12 05:33:43 j-devenish Exp $
 
5
|- #############################################################################
 
6
|       $Author: j-devenish $
 
7
+ ############################################################################## -->
 
8
<xsl:stylesheet
 
9
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 
10
        xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
 
11
        exclude-result-prefixes="doc" version='1.0'>
 
12
 
 
13
        <doc:reference name="admonition" xmlns="">
 
14
                <referenceinfo>
 
15
                        <releaseinfo role="meta">
 
16
                                $Id: admonition.mod.xsl,v 1.15 2004/08/12 05:33:43 j-devenish Exp $
 
17
                        </releaseinfo>
 
18
                        <authorgroup>
 
19
                                &ramon;
 
20
                                &james;
 
21
                        </authorgroup>
 
22
                        <copyright>
 
23
                                <year>2000</year><year>2001</year><year>2002</year><year>2003</year>
 
24
                                <holder>Ramon Casellas</holder>
 
25
                        </copyright>
 
26
                        <revhistory>
 
27
                                <doc:revision rcasver="1.6">&rev_2003_05;</doc:revision>
 
28
                        </revhistory>
 
29
                </referenceinfo>
 
30
                <title>Admonitions <filename>admonition.mod.xsl</filename></title>
 
31
                <partintro>
 
32
                        <para>
 
33
                        
 
34
                        &DocBook; includes admonitions (<doc:db>warning</doc:db>,
 
35
                        <doc:db>tip</doc:db>, <doc:db>important</doc:db>,
 
36
                        <doc:db>caution</doc:db>, <doc:db>note</doc:db>), which are set off
 
37
                        from the main text. &DB2LaTeX; places these in the normal text flow
 
38
                        but surrounds them with a box border.
 
39
                        
 
40
                        </para>
 
41
                        <doc:variables>
 
42
                                <itemizedlist>
 
43
                                        <listitem><simpara><xref linkend="param.latex.use.fancybox"/></simpara></listitem>
 
44
                                        <listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
 
45
                                        <listitem><simpara><xref linkend="param.latex.admonition.imagesize"/></simpara></listitem>
 
46
                                        <listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
 
47
                                </itemizedlist>
 
48
                        </doc:variables>
 
49
                </partintro>
 
50
        </doc:reference>
 
51
 
 
52
        <doc:param xmlns="">
 
53
                <refpurpose>
 
54
                        Declares a new environment to be used for admonitions
 
55
                </refpurpose>
 
56
                <doc:description>
 
57
                        <para>
 
58
 
 
59
                        This &LaTeX; environment is emitted during the preamble. That
 
60
                        environment has two mandatory parameters. Instances of the
 
61
                        environment are customised for each admonition via those
 
62
                        parameters. Instances will be typeset as boxed areas in the
 
63
                        document flow.
 
64
 
 
65
                        </para>
 
66
                        <para>
 
67
 
 
68
                        The first argument is the filename for graphics (e.g.
 
69
                        <filename>$admon.graphics.path/warning</filename>).
 
70
                        The second argument is the admonition title or the associated
 
71
                        generic text.
 
72
 
 
73
                        </para>
 
74
 
 
75
                        <example>
 
76
                                <title>Processing the <doc:db>warning</doc:db> admonition</title>
 
77
                                <para> When processing the admonition, the following code is generated: </para>
 
78
                                <programlisting>
 
79
                                <![CDATA[\begin{admonition}{figures/warning}{My WARNING}
 
80
...
 
81
\end{admonition}]]>
 
82
                                </programlisting>
 
83
                        </example>
 
84
                </doc:description>
 
85
                <doc:notes>
 
86
                        <!-- notes about spacing? -->
 
87
                        <para>
 
88
                                The environment uses graphics by default. This may generate errors or warnings
 
89
                                if &LaTeX; cannot find the graphics. If necessary, graphics may be disabled
 
90
                                via <xref linkend="param.admon.graphics.path"/>.
 
91
                        </para>
 
92
                </doc:notes>
 
93
                <!--
 
94
                <doc:seealso>
 
95
                        <itemizedlist>
 
96
                                <listitem><simpara><xref linkend="template.para"/></simpara></listitem>
 
97
                        </itemizedlist>
 
98
                </doc:seealso>
 
99
                -->
 
100
                <doc:variables>
 
101
                        <itemizedlist>
 
102
                                <listitem><simpara><xref linkend="param.latex.use.fancybox"/></simpara></listitem>
 
103
                                <listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
 
104
                                <listitem><simpara><xref linkend="param.latex.admonition.imagesize"/></simpara></listitem>
 
105
                                <listitem><simpara><xref linkend="param.latex.admonition.title.style"/></simpara></listitem>
 
106
                        </itemizedlist>
 
107
                </doc:variables>
 
108
        </doc:param>
 
109
 
 
110
        <xsl:param name="latex.admonition.environment">
 
111
                <xsl:text>% ----------------------------------------------&#10;</xsl:text>
 
112
                <xsl:text>% Define a new LaTeX environment (adminipage)&#10;</xsl:text>
 
113
                <xsl:text>% ----------------------------------------------&#10;</xsl:text>
 
114
                <xsl:text>\newenvironment{admminipage}%&#10;</xsl:text>
 
115
                <xsl:text>{ % this code corresponds to the \begin{adminipage} command&#10;</xsl:text>
 
116
                <xsl:text> \begin{Sbox}%&#10;</xsl:text>
 
117
                <xsl:text> \begin{minipage}%&#10;</xsl:text>
 
118
                <xsl:text>} %done&#10;</xsl:text>
 
119
                <xsl:text>{ % this code corresponds to the \end{adminipage} command&#10;</xsl:text>
 
120
                <xsl:text> \end{minipage}&#10;</xsl:text>
 
121
                <xsl:text> \end{Sbox}&#10;</xsl:text>
 
122
                <xsl:text> \fbox{\TheSbox}&#10;</xsl:text>
 
123
                <xsl:text>} %done&#10;</xsl:text>
 
124
                <xsl:text>% ----------------------------------------------&#10;</xsl:text>
 
125
                <xsl:text>% Define a new LaTeX length (admlength)&#10;</xsl:text>
 
126
                <xsl:text>% ----------------------------------------------&#10;</xsl:text>
 
127
                <xsl:text>\newlength{\admlength}&#10;</xsl:text>
 
128
                <xsl:text>% ----------------------------------------------&#10;</xsl:text>
 
129
                <xsl:text>% Define a new LaTeX environment (admonition)&#10;</xsl:text>
 
130
                <xsl:text>% With 2 parameters:&#10;</xsl:text>
 
131
                <xsl:text>% #1 The file (e.g. note.pdf)&#10;</xsl:text>
 
132
                <xsl:text>% #2 The caption&#10;</xsl:text>
 
133
                <xsl:text>% ----------------------------------------------&#10;</xsl:text>
 
134
                <xsl:text>\newenvironment{admonition}[2] &#10;</xsl:text>
 
135
                <xsl:text>{ % this code corresponds to the \begin{admonition} command&#10;</xsl:text>
 
136
                <xsl:text> \hspace{0mm}\newline\hspace*\fill\newline&#10;</xsl:text>
 
137
                <xsl:text> \noindent&#10;</xsl:text>
 
138
                <xsl:text> \setlength{\fboxsep}{5pt}&#10;</xsl:text>
 
139
                <xsl:text> \setlength{\admlength}{\linewidth}&#10;</xsl:text>
 
140
                <xsl:text> \addtolength{\admlength}{-10\fboxsep}&#10;</xsl:text>
 
141
                <xsl:text> \addtolength{\admlength}{-10\fboxrule}&#10;</xsl:text>
 
142
                <xsl:text> \admminipage{\admlength}&#10;</xsl:text>
 
143
                <xsl:text> {</xsl:text>
 
144
                <xsl:value-of select="$latex.admonition.title.style"/>
 
145
                <xsl:text>{#2}}</xsl:text>
 
146
                <xsl:text> \newline&#10;</xsl:text>
 
147
                <xsl:text> \\[1mm]&#10;</xsl:text>
 
148
                <xsl:text> \sffamily&#10;</xsl:text>
 
149
                <!--
 
150
                If we cannot find the admon.graphics.path;
 
151
                Comment out the next line (\includegraphics).
 
152
                This tactic is to avoid deleting the \includegraphics
 
153
                altogether, as that could confuse a person trying to
 
154
                find the use of parameter #1 in the environment.
 
155
                -->
 
156
                <xsl:if test="$admon.graphics.path=''">
 
157
                        <xsl:text>%</xsl:text>
 
158
                </xsl:if>
 
159
                <xsl:text> \includegraphics[</xsl:text> <xsl:value-of select="$latex.admonition.imagesize" /> <xsl:text>]{#1}&#10;</xsl:text>
 
160
                <xsl:text> \addtolength{\admlength}{-1cm}&#10;</xsl:text>
 
161
                <xsl:text> \addtolength{\admlength}{-20pt}&#10;</xsl:text>
 
162
                <xsl:text> \begin{minipage}[lt]{\admlength}&#10;</xsl:text>
 
163
                <xsl:text> \parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt&#10;</xsl:text>
 
164
                <xsl:text>} %done&#10;</xsl:text>
 
165
                <xsl:text>{ % this code corresponds to the \end{admonition} command&#10;</xsl:text>
 
166
                <xsl:text> \vspace{5mm} &#10;</xsl:text>
 
167
                <xsl:text> \end{minipage}&#10;</xsl:text>
 
168
                <xsl:text> \endadmminipage&#10;</xsl:text>
 
169
                <xsl:text> \vspace{.5em}&#10;</xsl:text>
 
170
                <xsl:text> \par&#10;</xsl:text>
 
171
                <xsl:text>}&#10;</xsl:text>
 
172
        </xsl:param>
 
173
 
 
174
        <doc:template xmlns="">
 
175
                <refpurpose> Choose an admonition graphic </refpurpose>
 
176
                <doc:description>
 
177
                        <para>
 
178
 
 
179
                        For each admonition element
 
180
                        (<doc:db>warning</doc:db>, <doc:db>tip</doc:db>, <doc:db>important</doc:db>, <doc:db>caution</doc:db>, <doc:db>note</doc:db>),
 
181
                        this template chooses the graphics filename. If the admonition element is
 
182
                        not known, the <doc:db>note</doc:db> graphic is used.
 
183
 
 
184
                        </para>
 
185
                </doc:description>
 
186
                <doc:params>
 
187
                        <variablelist>
 
188
                                <varlistentry>
 
189
                                        <term>name</term>
 
190
                                        <listitem>
 
191
                                                <para>
 
192
 
 
193
                                                        The name of the adminition. &DB2LaTeX; includes
 
194
                                                        different graphics for different adminitions. By
 
195
                                                        default, <literal>name</literal> defaults to the
 
196
                                                        XSLT <function
 
197
                                                        condition="xslt">local-name</function> of the
 
198
                                                        current node.
 
199
 
 
200
                                                </para>
 
201
                                        </listitem>
 
202
                                </varlistentry>
 
203
                        </variablelist>
 
204
                </doc:params>
 
205
        </doc:template>
 
206
 
 
207
        <xsl:template name="admon.graphic">
 
208
                <xsl:param name="name" select="local-name(.)"/>
 
209
                <xsl:choose>
 
210
                        <xsl:when test="$name='note'">note</xsl:when>
 
211
                        <xsl:when test="$name='warning'">warning</xsl:when>
 
212
                        <xsl:when test="$name='caution'">caution</xsl:when>
 
213
                        <xsl:when test="$name='tip'">tip</xsl:when>
 
214
                        <xsl:when test="$name='important'">important</xsl:when>
 
215
                        <xsl:otherwise>note</xsl:otherwise>
 
216
                </xsl:choose>
 
217
        </xsl:template>
 
218
 
 
219
        <doc:template xmlns="">
 
220
                <refpurpose> Process admonitions </refpurpose>
 
221
                <doc:description>
 
222
                        <para>
 
223
 
 
224
                        Invokes the environment provided by <xref
 
225
                        linkend="param.latex.admonition.environment"/>
 
226
                        and applies templates.
 
227
 
 
228
                        </para>
 
229
                        <note><para>An admonition will look something like this <doc:db>note</doc:db>.</para></note>
 
230
                </doc:description>
 
231
                <doc:notes>
 
232
                        <para>
 
233
 
 
234
                        There can be <quote>excessive</quote> whitespace between
 
235
                        the bottom of the admonition area and a subsequent paragraph.
 
236
 
 
237
                        </para>
 
238
                </doc:notes>
 
239
                <doc:variables>
 
240
                        <itemizedlist>
 
241
                                <listitem><simpara><xref linkend="param.admon.graphics.path"/></simpara></listitem>
 
242
                                <listitem><simpara><xref linkend="param.latex.apply.title.templates.admonitions"/></simpara></listitem>
 
243
                        </itemizedlist>
 
244
                </doc:variables>
 
245
                <doc:samples>
 
246
                        <simplelist type='inline'>
 
247
                                &test_adm;
 
248
                                &test_bind;
 
249
                                &test_book;
 
250
                        </simplelist>
 
251
                </doc:samples>
 
252
                <doc:seealso>
 
253
                        <itemizedlist>
 
254
                                <listitem><para>&mapping;</para></listitem>
 
255
                        </itemizedlist>
 
256
                </doc:seealso>
 
257
        </doc:template>
 
258
 
 
259
        <xsl:template match="note|important|warning|caution|tip">
 
260
                <xsl:call-template name="map.begin">
 
261
                        <xsl:with-param name="keyword">admonition</xsl:with-param>
 
262
                        <xsl:with-param name="string">
 
263
                                <xsl:text>{</xsl:text>
 
264
                                <xsl:value-of select="$admon.graphics.path"/><xsl:text>/</xsl:text>
 
265
                                <xsl:call-template name="admon.graphic"/>
 
266
                                <xsl:text>}{</xsl:text>
 
267
                                <xsl:choose>
 
268
                                        <xsl:when test="title and $latex.apply.title.templates.admonitions='1'">
 
269
                                                <xsl:call-template name="extract.object.title">
 
270
                                                        <xsl:with-param name="object" select="."/>
 
271
                                                </xsl:call-template>
 
272
                                        </xsl:when>
 
273
                                        <xsl:otherwise>
 
274
                                                <xsl:call-template name="gentext.element.name"/>
 
275
                                        </xsl:otherwise>
 
276
                                </xsl:choose>
 
277
                                <xsl:text>}</xsl:text>
 
278
                        </xsl:with-param>
 
279
                </xsl:call-template>
 
280
                <xsl:call-template name="content-templates"/>
 
281
                <xsl:call-template name="map.end">
 
282
                        <xsl:with-param name="keyword">admonition</xsl:with-param>
 
283
                </xsl:call-template>
 
284
        </xsl:template>
 
285
 
 
286
</xsl:stylesheet>