Moving docs tree to docs-xml to make room for generated docs in the release tarball.
[kai/samba.git] / docs-xml / xslt / db2latex-xsl / xsl / formal.mod.xsl
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3 <!--############################################################################# 
4 |       $Id: formal.mod.xsl,v 1.13 2004/01/03 09:48:34 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 id="formal" xmlns="">
14                 <referenceinfo>
15                         <releaseinfo role="meta">
16                                 $Id: formal.mod.xsl,v 1.13 2004/01/03 09:48:34 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.10">&rev_2003_05;</doc:revision>
28                         </revhistory>
29                 </referenceinfo>
30                 <title>Formal Objects <filename>formal.mod.xsl</filename></title>
31                 <partintro>
32                         <para>The file <filename>formal.mod.xsl</filename> contains generic
33                         XSL templates for <quote>formal</quote> (title-bearing, block-style)
34                         components and <quote>informal</quote> (no-title, block-style)
35                         components.
36                         It also contains templates for <doc:db>equation</doc:db>
37                         and <doc:db>informalequation</doc:db> (which should probably
38                         be moved to <filename>block.mod.xsl</filename>).</para>
39                 </partintro>
40         </doc:reference>
41
42         <doc:template xmlns="">
43                 <refpurpose> Typeset a formal object generically </refpurpose>
44                 <doc:description>
45                         <para>
46                                 This template formats the current node as a formal object
47                                 by calling <xref linkend="template.formal.object.title"/>
48                                 then <xref linkend="template.content-templates"/>.
49                         </para>
50                 </doc:description>
51                 <doc:variables>
52                         &no_var;
53                 </doc:variables>
54                 <doc:seealso>
55                         <itemizedlist>
56                                 <listitem><simpara><xref linkend="template.formal.object.title"/></simpara></listitem>
57                                 <listitem><simpara><xref linkend="template.content-templates"/></simpara></listitem>
58                         </itemizedlist>
59                 </doc:seealso>
60         </doc:template>
61         <xsl:template name="formal.object">
62                 <xsl:call-template name="formal.object.title"/>
63                 <xsl:call-template name="content-templates"/>
64         </xsl:template>
65
66         <doc:template xmlns="">
67                 <refpurpose> Typeset the title of a formal object generically </refpurpose>
68                 <doc:description>
69                         <para>
70
71                                 Outputs an anchor for cross-references and hyper-links, then
72                                 applies templates in the <literal>title.content</literal> mode
73                                 (supported by <filename>common/common.xsl</filename>)
74
75                         </para>
76                 </doc:description>
77                 <doc:variables>
78                         &no_var;
79                 </doc:variables>
80         </doc:template>
81         <xsl:template name="formal.object.title">
82                 <xsl:param name="title">
83                         <xsl:apply-templates select="." mode="title.content"/>
84                 </xsl:param>
85                 <xsl:call-template name="label.id"/>
86                 <xsl:copy-of select="$title"/>
87         </xsl:template>
88
89         <doc:template xmlns="">
90                 <refpurpose> Typeset an informal object generically </refpurpose>
91                 <doc:description>
92                         <para>
93
94                                 Outputs an anchor for cross-references and hyper-links, then
95                                 applies all templates.
96
97                         </para>
98                 </doc:description>
99                 <doc:variables>
100                         &no_var;
101                 </doc:variables>
102         </doc:template>
103         <xsl:template name="informal.object">
104                 <xsl:call-template name="label.id"/>
105                 <xsl:apply-templates/>
106         </xsl:template>
107
108         <doc:template xmlns="">
109                 <refpurpose> Typeset formal or informal object generically </refpurpose>
110                 <doc:description>
111                         <para>
112
113                                 Chooses whether the current node is a <quote>formal</quote>-
114                                 or <quote>informal</quote>-like object and calls either
115                                 <xref linkend="template.formal.object"/> or
116                                 <xref linkend="template.informal.object"/>.
117
118                         </para>
119                 </doc:description>
120                 <doc:variables>
121                         &no_var;
122                 </doc:variables>
123         </doc:template>
124         <xsl:template name="semiformal.object">
125                 <xsl:choose>
126                         <xsl:when test="title"><xsl:call-template name="formal.object"/></xsl:when>
127                         <xsl:otherwise><xsl:call-template name="informal.object"/></xsl:otherwise>
128                 </xsl:choose>
129         </xsl:template>
130
131         <doc:template xmlns="">
132                 <refpurpose> Determine the relative position for a <doc:db>caption</doc:db> </refpurpose>
133                 <doc:description>
134                         <para>
135                                 Chooses the position of a caption to be <quote>before</quote>
136                                 or <quote>after</quote> the selected object.
137                         </para>
138                 </doc:description>
139                 <doc:variables>
140                         <itemizedlist>
141                                 <listitem><simpara><xref linkend="param.formal.title.placement"/></simpara></listitem>
142                         </itemizedlist>
143                 </doc:variables>
144                 <doc:params>
145                         <variablelist>
146                                 <varlistentry>
147                                         <term>object</term>
148                                         <listitem>
149                                                 <para>
150
151                                                 The type of object (i.e. name of the element) to which the caption pertains.
152
153                                                 </para>
154                                         </listitem>
155                                 </varlistentry>
156                         </variablelist>
157                 </doc:params>
158                 <doc:notes>
159                         <para>
160
161                                 If <quote>after</quote> has not been specified for the given
162                                 object in <xref linkend="param.formal.title.placement"/>,
163                                 <quote>before</quote> will be used by default.
164
165                         </para>
166                 </doc:notes>
167         </doc:template>
168         <xsl:template name="generate.formal.title.placement">
169                 <xsl:param name="object" select="figure" />
170                 <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),concat($object, ' '))"/>
171                 <xsl:choose>
172                         <xsl:when test="contains($param.placement, ' ')">
173                                 <xsl:value-of select="substring-before($param.placement, ' ')"/>
174                         </xsl:when>
175                         <xsl:when test="$param.placement = ''">before</xsl:when>
176                         <xsl:otherwise>
177                                 <xsl:value-of select="$param.placement"/>
178                         </xsl:otherwise>
179                 </xsl:choose>
180         </xsl:template>
181
182         <!-- ========================================  -->
183         <!-- XSL Template for DocBook Equation Element -->
184         <!-- 2003/07/04 Applied patches from J.Pavlovic -->
185         <!-- ========================================  -->
186         <doc:template xmlns="">
187                 <refpurpose>Process <doc:db>equation</doc:db> elements</refpurpose>
188                 <doc:description>
189                         <para>
190                                 Formats an titled, block-style equation.
191                         </para>
192                 </doc:description>
193                 <doc:variables>
194                         <itemizedlist>
195                                 <listitem><simpara><xref linkend="param.latex.equation.caption.style"/></simpara></listitem>
196                                 <listitem><simpara><xref linkend="param.latex.alt.is.preferred"/></simpara></listitem>
197                         </itemizedlist>
198                 </doc:variables>
199                 <doc:notes>
200                         <para>
201
202                                 If an <doc:db>informalequation</doc:db> is present, it will be
203                                 typeset in preference to any other elements. Otherwise, this
204                                 template will follow the same logic as the <xref
205                                 linkend="template.informalequation"/> template.
206
207                         </para>
208                 </doc:notes>
209                 <doc:samples>
210                         <simplelist type='inline'>
211                                 &test_book;
212                         </simplelist>
213                 </doc:samples>
214                 <doc:seealso>
215                         <itemizedlist>
216                                 <listitem><simpara>&mapping;</simpara></listitem>
217                                 <listitem><simpara><xref linkend="template.generate.formal.title.placement"/></simpara></listitem>
218                         </itemizedlist>
219                 </doc:seealso>
220         </doc:template>
221         <xsl:template match="equation">
222                 <!-- Equation title placement -->
223                 <xsl:variable name="placement">
224                         <xsl:call-template name="generate.formal.title.placement">
225                                 <xsl:with-param name="object" select="local-name(.)" />
226                         </xsl:call-template>
227                 </xsl:variable>
228                 <!-- Equation caption -->
229                 <xsl:variable name="caption">
230                         <xsl:text>{</xsl:text>
231                         <xsl:value-of select="$latex.equation.caption.style"/>
232                         <xsl:text>{\caption{</xsl:text>
233                         <xsl:apply-templates select="title" mode="caption.mode"/>
234                         <xsl:text>}</xsl:text>
235                         <xsl:call-template name="label.id"/>
236                         <xsl:text>}}&#10;</xsl:text>
237                 </xsl:variable>
238                 <xsl:call-template name="map.begin"/>
239                 <xsl:if test="$placement='before'">
240                         <xsl:text>\captionswapskip{}</xsl:text>
241                         <xsl:value-of select="$caption" />
242                         <xsl:text>\captionswapskip{}</xsl:text>
243                 </xsl:if>
244                 <xsl:choose>
245                         <xsl:when test="informalequation">
246                                 <xsl:apply-templates select="informalequation"/>
247                         </xsl:when>
248                         <xsl:otherwise>
249                                 <xsl:variable name="tex" select="alt[@role='tex' or @role='latex']|mediaobject/textobject[@role='tex' or @role='latex']|mediaobject/textobject/phrase[@role='tex' or @role='latex']"/>
250                                 <xsl:choose>
251                                         <xsl:when test="$tex">
252                                                 <xsl:apply-templates select="$tex"/>
253                                         </xsl:when>
254                                         <xsl:when test="alt and $latex.alt.is.preferred='1'">
255                                                 <xsl:apply-templates select="alt"/>
256                                         </xsl:when>
257                                         <xsl:when test="mediaobject">
258                                                 <xsl:apply-templates select="mediaobject"/>
259                                         </xsl:when>
260                                         <xsl:when test="alt">
261                                                 <xsl:apply-templates select="alt"/>
262                                         </xsl:when>
263                                         <xsl:otherwise>
264                                                 <xsl:apply-templates select="graphic"/>
265                                         </xsl:otherwise>
266                                 </xsl:choose>
267                         </xsl:otherwise>
268                 </xsl:choose>
269                 <xsl:if test="$placement!='before'"><xsl:value-of select="$caption" /></xsl:if>
270                 <xsl:call-template name="map.end"/>
271         </xsl:template>
272
273         <doc:template xmlns="">
274                 <refpurpose>Process <doc:db>informalequation</doc:db> elements</refpurpose>
275                 <doc:description>
276                         <para>
277                                 Formats an untitled, block-style equation.
278                         </para>
279                 </doc:description>
280                 <doc:variables>
281                         <itemizedlist>
282                                 <listitem><simpara><xref linkend="param.latex.alt.is.preferred"/></simpara></listitem>
283                         </itemizedlist>
284                 </doc:variables>
285                 <doc:notes>
286                         <para>
287
288                                 The <quote>equation</quote> will be found by searching the
289                                 <sgmltag>informalequation</sgmltag> for its <quote>most
290                                 appropriate</quote> child elements. Firstly, this template will
291                                 search for all <doc:db>alt</doc:db>, <doc:db
292                                 basename="textobject">mediaobject/textobject</doc:db> or
293                                 <doc:db
294                                 basename="phrase">mediaobject/textobject/phrase</doc:db>
295                                 children that have a &roleattr; of <quote>latex</quote> or
296                                 <quote>tex</quote>. If none were found, the template will
297                                 search for generic <doc:db>mediaobject</doc:db> or
298                                 <doc:db>alt</doc:db> children. If <xref
299                                 linkend="param.latex.alt.is.preferred"/> is set, <sgmltag
300                                 basename="alt">alts</sgmltag> will be preferred over <sgmltag
301                                 basename="mediaobject">mediaobjects</sgmltag>. If none of these
302                                 elements was found, the template will format any
303                                 <doc:db>graphic</doc:db> children.
304
305                         </para>
306                 </doc:notes>
307                 <doc:samples>
308                         <simplelist type='inline'>
309                                 &test_book;
310                                 <!--
311                                 &test_pavlov;
312                                 -->
313                         </simplelist>
314                 </doc:samples>
315                 <doc:seealso>
316                         <itemizedlist>
317                                 <listitem><simpara>&mapping;</simpara></listitem>
318                         </itemizedlist>
319                 </doc:seealso>
320         </doc:template>
321         <xsl:template match="informalequation">
322                 <xsl:variable name="tex" select="alt[@role='tex' or @role='latex']|mediaobject/textobject[@role='tex' or @role='latex']|mediaobject/textobject/phrase[@role='tex' or @role='latex']"/>
323                 <xsl:text>&#10;</xsl:text>
324                 <xsl:choose>
325                         <xsl:when test="$tex">
326                                 <xsl:apply-templates select="$tex"/>
327                         </xsl:when>
328                         <xsl:when test="alt and $latex.alt.is.preferred='1'">
329                                 <xsl:apply-templates select="alt"/>
330                         </xsl:when>
331                         <xsl:when test="mediaobject">
332                                 <xsl:apply-templates select="mediaobject"/>
333                         </xsl:when>
334                         <xsl:when test="alt">
335                                 <xsl:apply-templates select="alt"/>
336                         </xsl:when>
337                         <xsl:otherwise>
338                                 <xsl:apply-templates select="graphic"/>
339                         </xsl:otherwise>
340                 </xsl:choose>
341                 <xsl:text>&#10;&#10;</xsl:text>
342         </xsl:template>
343
344 </xsl:stylesheet>