Next update of VFS modules development guide
[kai/samba-autobuild/.git] / docs-xml / xslt / db2latex-xsl / xsl / procedure.mod.xsl
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3 <!--############################################################################# 
4 |       $Id: procedure.mod.xsl,v 1.12 2004/01/13 04:35:43 j-devenish Exp $
5 |- #############################################################################
6 |       $Author: j-devenish $
7 + ############################################################################## -->
8
9 <xsl:stylesheet
10         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11         xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
12         exclude-result-prefixes="doc" version='1.0'>
13
14         <doc:reference id="procedure" xmlns="">
15                 <referenceinfo>
16                         <releaseinfo role="meta">
17                                 $Id: procedure.mod.xsl,v 1.12 2004/01/13 04:35:43 j-devenish Exp $
18                         </releaseinfo>
19                         <authorgroup>
20                                 &ramon;
21                                 &james;
22                         </authorgroup>
23                         <copyright>
24                                 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
25                                 <holder>Ramon Casellas</holder>
26                         </copyright>
27                         <revhistory>
28                                 <doc:revision rcasver="1.10">&rev_2003_05;</doc:revision>
29                         </revhistory>
30                 </referenceinfo>
31                 <title>Procedures <filename>procedure.mod.xsl</filename></title>
32                 <partintro>
33                         <para>
34                         
35                         
36                         
37                         </para>
38                 </partintro>
39         </doc:reference>
40
41         <doc:template xmlns="">
42                 <refpurpose>Process <doc:db>procedure</doc:db> elements</refpurpose>
43                 <doc:description>
44                         <para>
45                         
46                         Format a titled, enumerated list of steps.
47                         
48                         </para>
49                 </doc:description>
50                 <doc:variables>
51                         <itemizedlist>
52                                 <listitem><simpara><xref linkend="param.formal.title.placement"/></simpara></listitem>
53                         </itemizedlist>
54                 </doc:variables>
55                 <doc:params>
56                         <variablelist>
57                                 <varlistentry>
58                                         <term>mode</term>
59                                         <listitem><simpara>
60                                                 Although the <sgmltag class="attribute">mode</sgmltag>
61                                                 parameter is normally empty, this template recognises a
62                                                 special value of <quote>custom</quote>. This influences
63                                                 the type of environment and the method of labelling
64                                                 <doc:db basename="step">steps</doc:db>.
65                                         </simpara></listitem>
66                                 </varlistentry>
67                                 <varlistentry>
68                                         <term>environment</term>
69                                         <listitem><simpara>
70                                                 This determines the &LaTeX; environment that will be
71                                                 used for each <doc:db>step</doc:db>'s <function
72                                                 condition="latex">item</function>. When the
73                                                 <literal>mode</literal> is <quote>custom</quote>, this
74                                                 parameter defaults to <quote>description</quote>.
75                                                 Otherwise, the default is <quote>enumerate</quote>.
76                                         </simpara></listitem>
77                                 </varlistentry>
78                         </variablelist>
79                 </doc:params>
80                 <doc:notes>
81                         <para>
82                         
83                         By default, the &LaTeX; <function
84                         condition="env">enumerate</function> environment is used and any
85                         <doc:db>step</doc:db>'s <doc:db>title</doc:db> will be typeset
86                         after its automatic step number. However, when the
87                         <literal>mode</literal> variable is equal to <quote>custom</quote>,
88                         the <function condition="env">description</function> environment
89                         will be used and step titles will be typeset
90                         <emphasis>instead</emphasis> of step numbers.
91                         
92                         </para>
93                         <para>
94
95                         Although the procedure is a formal, titled block, is is not typeset
96                         using <function condition="latex">subsection</function>.
97
98                         </para>
99                 </doc:notes>
100                 <doc:samples>
101                         <simplelist type='inline'>
102                                 &test_book;
103                                 &test_chemistry;
104                                 &test_procedure;
105                         </simplelist>
106                 </doc:samples>
107                 <doc:seealso>
108                         <itemizedlist>
109                                 <listitem><simpara><xref linkend="template.procedure/title"/></simpara></listitem>
110                         </itemizedlist>
111                 </doc:seealso>
112         </doc:template>
113         <xsl:template match="procedure" name="procedure">
114                 <xsl:param name="mode" select="''"/>
115                 <xsl:param name="environment">
116                         <xsl:choose>
117                                 <xsl:when test="$mode='custom'">
118                                         <xsl:text>description</xsl:text>
119                                 </xsl:when>
120                                 <xsl:otherwise>
121                                         <xsl:text>enumerate</xsl:text>
122                                 </xsl:otherwise>
123                         </xsl:choose>
124                 </xsl:param>
125                 <xsl:variable name="placement">
126                         <xsl:call-template name="generate.formal.title.placement">
127                                 <xsl:with-param name="object" select="local-name(.)" />
128                         </xsl:call-template>
129                 </xsl:variable>
130                 <xsl:variable name="preamble" select="node()[not(self::blockinfo or self::title or self::subtitle or self::titleabbrev or self::step)]"/>
131                 <xsl:choose>
132                         <xsl:when test="$placement='before' or $placement=''">
133                                 <xsl:apply-templates select="title" mode="procedure.title"/>
134                                 <xsl:apply-templates select="$preamble"/>
135                                 <xsl:text>\begin{</xsl:text>
136                                 <xsl:value-of select="$environment"/>
137                                 <xsl:text>}&#10;</xsl:text>
138                                 <xsl:apply-templates select="step">
139                                         <xsl:with-param name="mode" select="$mode"/>
140                                 </xsl:apply-templates>
141                                 <xsl:text>\end{</xsl:text>
142                                 <xsl:value-of select="$environment"/>
143                                 <xsl:text>}&#10;</xsl:text>
144                         </xsl:when>
145                         <xsl:otherwise>
146                                 <xsl:apply-templates select="$preamble"/>
147                                 <xsl:text>\begin{</xsl:text>
148                                 <xsl:value-of select="$environment"/>
149                                 <xsl:text>}&#10;</xsl:text>
150                                 <xsl:apply-templates select="step">
151                                         <xsl:with-param name="mode" select="$mode"/>
152                                 </xsl:apply-templates>
153                                 <xsl:text>\end{</xsl:text>
154                                 <xsl:value-of select="$environment"/>
155                                 <xsl:text>}&#10;</xsl:text>
156                                 <xsl:apply-templates select="title" mode="procedure.title"/>
157                         </xsl:otherwise>
158                 </xsl:choose>
159         </xsl:template>
160
161         <doc:template xmlns="">
162                 <refpurpose>Process a <doc:db>procedure</doc:db>'s <doc:db>title</doc:db> </refpurpose>
163                 <doc:description>
164                         <para>
165                         
166                         Format a special bridgehead.
167                         
168                         </para>
169                 </doc:description>
170                 <doc:variables>
171                         <itemizedlist>
172                                 <listitem><simpara><xref linkend="param.latex.procedure.title.style"/></simpara></listitem>
173                                 <listitem><simpara><xref linkend="param.latex.apply.title.templates"/></simpara></listitem>
174                         </itemizedlist>
175                 </doc:variables>
176                 <doc:notes>
177                         <para>
178                         
179                         The title is typeset as a paragraph.
180                         
181                         </para>
182                 </doc:notes>
183                 <doc:samples>
184                         <simplelist type='inline'>
185                                 &test_book;
186                                 &test_procedure;
187                         </simplelist>
188                 </doc:samples>
189         </doc:template>
190         <xsl:template match="procedure/title">
191                 <xsl:text>&#10;&#10;{</xsl:text>
192                 <xsl:value-of select="$latex.procedure.title.style"/>
193                 <xsl:text>{</xsl:text>
194                 <xsl:choose>
195                         <xsl:when test="$latex.apply.title.templates=1">
196                                 <xsl:apply-templates/>
197                         </xsl:when>
198                         <xsl:otherwise>
199                                 <xsl:value-of select="."/>
200                         </xsl:otherwise>
201                 </xsl:choose>
202                 <xsl:text>}}&#10;</xsl:text>
203         </xsl:template>
204
205         <doc:template basename="step" xmlns="">
206                 <refpurpose>Process <doc:db>step</doc:db> elements </refpurpose>
207                 <doc:description>
208                         <para>
209                         
210                         Format steps and substeps as part of a procedure.
211                         
212                         </para>
213                 </doc:description>
214                 <doc:variables>
215                         <itemizedlist>
216                                 <listitem><simpara><xref linkend="param.latex.step.title.style"/></simpara></listitem>
217                         </itemizedlist>
218                 </doc:variables>
219                 <doc:params>
220                         <variablelist>
221                                 <varlistentry>
222                                         <term>mode</term>
223                                         <listitem><simpara>
224
225                                                 The <quote>mode</quote> from the parent
226                                                 <doc:db>procedure</doc:db>. This template
227                                                 needs to know when the <quote>custom</quote>
228                                                 mode is in use, because it needs to pass the
229                                                 step's title as an optional argument to the
230                                                 &LaTeX; <function condition="latex">item</function>
231                                                 command (see <xref linkend="template.procedure"/>).
232                                                 The mode is normally received from the enclosing
233                                                 <doc:db>procedure</doc:db> or <doc:db>substeps</doc:db>
234                                                 template.
235
236                                         </simpara></listitem>
237                                 </varlistentry>
238                                 <varlistentry>
239                                         <term>title</term>
240                                         <listitem><simpara>
241                                                 The string (typically empty).
242                                                 See <xref linkend="template.generate.step.title"/>
243                                         </simpara></listitem>
244                                 </varlistentry>
245                         </variablelist>
246                 </doc:params>
247                 <doc:notes>
248                         <para>
249                         
250                         Each step is typeset using the &LaTeX; <function condition="latex">item</function> command.
251                         
252                         </para>
253                         <para>
254                                 If there is no <doc:db>title</doc:db> element, the
255                                 step will be numbered automatically by &LaTeX;.
256                         </para>
257                 </doc:notes>
258                 <doc:samples>
259                         <simplelist type='inline'>
260                                 &test_book;
261                                 &test_chemistry;
262                                 &test_procedure;
263                         </simplelist>
264                 </doc:samples>
265                 <doc:seealso>
266                         <itemizedlist>
267                                 <listitem><simpara><xref linkend="template.generate.step.title"/></simpara></listitem>
268                         </itemizedlist>
269                 </doc:seealso>
270         </doc:template>
271         <xsl:template match="step" name="step">
272                 <xsl:param name="mode" select="''"/>
273                 <xsl:param name="title">
274                         <xsl:call-template name="generate.step.title">
275                                 <xsl:with-param name="mode" select="$mode"/>
276                         </xsl:call-template>
277                 </xsl:param>
278                 <xsl:choose>
279                         <xsl:when test="$title!='' and $mode='custom'">
280                                 <xsl:text>&#10;\item[{</xsl:text>
281                                 <xsl:value-of select="$latex.step.title.style"/> <!-- by default \sc -->
282                                 <xsl:text>{</xsl:text>
283                                 <xsl:value-of select="$title"/>
284                                 <xsl:text>}}]&#10;{</xsl:text>
285                         </xsl:when>
286                         <xsl:when test="$title!=''">
287                                 <xsl:text>&#10;\item{{</xsl:text>
288                                 <xsl:value-of select="$latex.step.title.style"/> <!-- by default \sc -->
289                                 <xsl:text>{</xsl:text>
290                                 <xsl:value-of select="$title"/>
291                                 <xsl:text>}}&#10;</xsl:text>
292                         </xsl:when>
293                         <xsl:otherwise>
294                                 <xsl:text>&#10;\item{</xsl:text>
295                         </xsl:otherwise>
296                 </xsl:choose>
297                  <xsl:apply-templates select="node()[not(self::title)]"/>
298                 <xsl:text>}&#10;</xsl:text>
299         </xsl:template>
300
301         <doc:template xmlns="">
302                 <refpurpose>Generate a <doc:db>step</doc:db>'s title </refpurpose>
303                 <doc:description>
304                         <para>
305                         
306                         By default, simply applies templates for <doc:db>title</doc:db>
307                         elements.
308                         
309                         </para>
310                 </doc:description>
311                 <doc:variables>
312                         &no_var;
313                 </doc:variables>
314                 <doc:params>
315                         <variablelist>
316                                 <varlistentry>
317                                         <term>mode</term>
318                                         <listitem><simpara>
319
320                                                 See <xref linkend="template.procedure"/>. When the mode
321                                                 is <quote>custom</quote>, this template will use the
322                                                 XSL <literal>number</literal> element to format a title
323                                                 such as "1.", "2.", etc. Otherwise, any
324                                                 <doc:db>title</doc:db> elements will be used.
325
326                                         </simpara></listitem>
327                                 </varlistentry>
328                         </variablelist>
329                 </doc:params>
330                 <doc:notes>
331                         <para>
332
333                                 If this template generates no content, the
334                                 <doc:db>step</doc:db> will either be numbered automatically by
335                                 &LaTeX; or left unlabelled (depending on the
336                                 <quote>mode</quote>).
337
338                         </para>
339                 </doc:notes>
340         </doc:template>
341         <xsl:template name="generate.step.title">
342                 <xsl:param name="mode"/>
343                 <xsl:choose>
344                         <xsl:when test="title">
345                                 <xsl:apply-templates select="title"/>
346                         </xsl:when>
347                         <xsl:when test="$mode='custom'">
348                                 <xsl:number format="1."/>
349                         </xsl:when>
350                         <!-- otherwise, empty -->
351                 </xsl:choose>
352         </xsl:template>
353
354         <doc:template xmlns="">
355                 <refpurpose>Process <doc:db>substep</doc:db> elements </refpurpose>
356                 <doc:description>
357                         <para>
358                         
359                         Format substeps as part of a step.
360                         
361                         </para>
362                 </doc:description>
363                 <doc:variables>
364                         &no_var;
365                 </doc:variables>
366                 <doc:params>
367                         <variablelist>
368                                 <varlistentry>
369                                         <term>mode</term>
370                                         <listitem><simpara>
371                                                 See <xref linkend="template.procedure"/>.
372                                         </simpara></listitem>
373                                 </varlistentry>
374                                 <varlistentry>
375                                         <term>environment</term>
376                                         <listitem><simpara>
377                                                 See <xref linkend="template.procedure"/>.
378                                         </simpara></listitem>
379                                 </varlistentry>
380                         </variablelist>
381                 </doc:params>
382                 <doc:notes>
383                         <para>
384                         
385                         Substeps are typeset by nesting a &LaTeX;
386                         <function condition="env">enumerate</function> environment.
387                         
388                         </para>
389                 </doc:notes>
390                 <doc:samples>
391                         <simplelist type='inline'>
392                                 &test_book;
393                                 &test_procedure;
394                         </simplelist>
395                 </doc:samples>
396         </doc:template>
397         <xsl:template match="substeps">
398                 <xsl:param name="mode" select="''"/>
399                 <xsl:param name="environment">
400                         <xsl:choose>
401                                 <xsl:when test="$mode='custom'">
402                                         <xsl:text>description</xsl:text>
403                                 </xsl:when>
404                                 <xsl:otherwise>
405                                         <xsl:text>enumerate</xsl:text>
406                                 </xsl:otherwise>
407                         </xsl:choose>
408                 </xsl:param>
409                 <xsl:text>\begin{</xsl:text>
410                 <xsl:value-of select="$environment"/>
411                 <xsl:text>}&#10;</xsl:text>
412                 <xsl:apply-templates select="step">
413                         <xsl:with-param name="mode" select="$mode"/>
414                 </xsl:apply-templates>
415                 <xsl:text>\end{</xsl:text>
416                 <xsl:value-of select="$environment"/>
417                 <xsl:text>}&#10;</xsl:text>
418         </xsl:template>
419
420 </xsl:stylesheet>
421