summaryrefslogtreecommitdiff
path: root/docs-xml/xslt/db2latex-xsl/xsl/formal.mod.xsl
blob: f49bd9a85ada0e5de2c9b9d083b70a6820293e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?xml version='1.0'?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
<!--############################################################################# 
|	$Id: formal.mod.xsl,v 1.13 2004/01/03 09:48:34 j-devenish Exp $
|- #############################################################################
|	$Author: j-devenish $
+ ############################################################################## -->
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
	exclude-result-prefixes="doc" version='1.0'>

	<doc:reference id="formal" xmlns="">
		<referenceinfo>
			<releaseinfo role="meta">
				$Id: formal.mod.xsl,v 1.13 2004/01/03 09:48:34 j-devenish Exp $
			</releaseinfo>
			<authorgroup>
				&ramon;
				&james;
			</authorgroup>
			<copyright>
				<year>2000</year><year>2001</year><year>2002</year><year>2003</year>
				<holder>Ramon Casellas</holder>
			</copyright>
			<revhistory>
				<doc:revision rcasver="1.10">&rev_2003_05;</doc:revision>
			</revhistory>
		</referenceinfo>
		<title>Formal Objects <filename>formal.mod.xsl</filename></title>
		<partintro>
			<para>The file <filename>formal.mod.xsl</filename> contains generic
			XSL templates for <quote>formal</quote> (title-bearing, block-style)
			components and <quote>informal</quote> (no-title, block-style)
			components.
			It also contains templates for <doc:db>equation</doc:db>
			and <doc:db>informalequation</doc:db> (which should probably
			be moved to <filename>block.mod.xsl</filename>).</para>
		</partintro>
	</doc:reference>

	<doc:template xmlns="">
		<refpurpose> Typeset a formal object generically </refpurpose>
		<doc:description>
			<para>
				This template formats the current node as a formal object
				by calling <xref linkend="template.formal.object.title"/>
				then <xref linkend="template.content-templates"/>.
			</para>
		</doc:description>
		<doc:variables>
			&no_var;
		</doc:variables>
		<doc:seealso>
			<itemizedlist>
				<listitem><simpara><xref linkend="template.formal.object.title"/></simpara></listitem>
				<listitem><simpara><xref linkend="template.content-templates"/></simpara></listitem>
			</itemizedlist>
		</doc:seealso>
	</doc:template>
	<xsl:template name="formal.object">
		<xsl:call-template name="formal.object.title"/>
		<xsl:call-template name="content-templates"/>
	</xsl:template>

	<doc:template xmlns="">
		<refpurpose> Typeset the title of a formal object generically </refpurpose>
		<doc:description>
			<para>

				Outputs an anchor for cross-references and hyper-links, then
				applies templates in the <literal>title.content</literal> mode
				(supported by <filename>common/common.xsl</filename>)

			</para>
		</doc:description>
		<doc:variables>
			&no_var;
		</doc:variables>
	</doc:template>
	<xsl:template name="formal.object.title">
		<xsl:param name="title">
			<xsl:apply-templates select="." mode="title.content"/>
		</xsl:param>
		<xsl:call-template name="label.id"/>
		<xsl:copy-of select="$title"/>
	</xsl:template>

	<doc:template xmlns="">
		<refpurpose> Typeset an informal object generically </refpurpose>
		<doc:description>
			<para>

				Outputs an anchor for cross-references and hyper-links, then
				applies all templates.

			</para>
		</doc:description>
		<doc:variables>
			&no_var;
		</doc:variables>
	</doc:template>
	<xsl:template name="informal.object">
		<xsl:call-template name="label.id"/>
		<xsl:apply-templates/>
	</xsl:template>

	<doc:template xmlns="">
		<refpurpose> Typeset formal or informal object generically </refpurpose>
		<doc:description>
			<para>

				Chooses whether the current node is a <quote>formal</quote>-
				or <quote>informal</quote>-like object and calls either
				<xref linkend="template.formal.object"/> or
				<xref linkend="template.informal.object"/>.

			</para>
		</doc:description>
		<doc:variables>
			&no_var;
		</doc:variables>
	</doc:template>
	<xsl:template name="semiformal.object">
		<xsl:choose>
			<xsl:when test="title"><xsl:call-template name="formal.object"/></xsl:when>
			<xsl:otherwise><xsl:call-template name="informal.object"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<doc:template xmlns="">
		<refpurpose> Determine the relative position for a <doc:db>caption</doc:db> </refpurpose>
		<doc:description>
			<para>
				Chooses the position of a caption to be <quote>before</quote>
				or <quote>after</quote> the selected object.
			</para>
		</doc:description>
		<doc:variables>
			<itemizedlist>
				<listitem><simpara><xref linkend="param.formal.title.placement"/></simpara></listitem>
			</itemizedlist>
		</doc:variables>
		<doc:params>
			<variablelist>
				<varlistentry>
					<term>object</term>
					<listitem>
						<para>

						The type of object (i.e. name of the element) to which the caption pertains.

						</para>
					</listitem>
				</varlistentry>
			</variablelist>
		</doc:params>
		<doc:notes>
			<para>

				If <quote>after</quote> has not been specified for the given
				object in <xref linkend="param.formal.title.placement"/>,
				<quote>before</quote> will be used by default.

			</para>
		</doc:notes>
	</doc:template>
	<xsl:template name="generate.formal.title.placement">
		<xsl:param name="object" select="figure" />
		<xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),concat($object, ' '))"/>
		<xsl:choose>
			<xsl:when test="contains($param.placement, ' ')">
				<xsl:value-of select="substring-before($param.placement, ' ')"/>
			</xsl:when>
			<xsl:when test="$param.placement = ''">before</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$param.placement"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- ========================================  -->
	<!-- XSL Template for DocBook Equation Element -->
	<!-- 2003/07/04 Applied patches from J.Pavlovic -->
	<!-- ========================================  -->
	<doc:template xmlns="">
		<refpurpose>Process <doc:db>equation</doc:db> elements</refpurpose>
		<doc:description>
			<para>
				Formats an titled, block-style equation.
			</para>
		</doc:description>
		<doc:variables>
			<itemizedlist>
				<listitem><simpara><xref linkend="param.latex.equation.caption.style"/></simpara></listitem>
				<listitem><simpara><xref linkend="param.latex.alt.is.preferred"/></simpara></listitem>
			</itemizedlist>
		</doc:variables>
		<doc:notes>
			<para>

				If an <doc:db>informalequation</doc:db> is present, it will be
				typeset in preference to any other elements. Otherwise, this
				template will follow the same logic as the <xref
				linkend="template.informalequation"/> template.

			</para>
		</doc:notes>
		<doc:samples>
			<simplelist type='inline'>
				&test_book;
			</simplelist>
		</doc:samples>
		<doc:seealso>
			<itemizedlist>
				<listitem><simpara>&mapping;</simpara></listitem>
				<listitem><simpara><xref linkend="template.generate.formal.title.placement"/></simpara></listitem>
			</itemizedlist>
		</doc:seealso>
	</doc:template>
	<xsl:template match="equation">
		<!-- Equation title placement -->
		<xsl:variable name="placement">
			<xsl:call-template name="generate.formal.title.placement">
				<xsl:with-param name="object" select="local-name(.)" />
			</xsl:call-template>
		</xsl:variable>
		<!-- Equation caption -->
		<xsl:variable name="caption">
			<xsl:text>{</xsl:text>
			<xsl:value-of select="$latex.equation.caption.style"/>
			<xsl:text>{\caption{</xsl:text>
			<xsl:apply-templates select="title" mode="caption.mode"/>
			<xsl:text>}</xsl:text>
			<xsl:call-template name="label.id"/>
			<xsl:text>}}&#10;</xsl:text>
		</xsl:variable>
		<xsl:call-template name="map.begin"/>
		<xsl:if test="$placement='before'">
			<xsl:text>\captionswapskip{}</xsl:text>
			<xsl:value-of select="$caption" />
			<xsl:text>\captionswapskip{}</xsl:text>
		</xsl:if>
		<xsl:choose>
			<xsl:when test="informalequation">
				<xsl:apply-templates select="informalequation"/>
			</xsl:when>
			<xsl:otherwise>
				<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']"/>
				<xsl:choose>
					<xsl:when test="$tex">
						<xsl:apply-templates select="$tex"/>
					</xsl:when>
					<xsl:when test="alt and $latex.alt.is.preferred='1'">
						<xsl:apply-templates select="alt"/>
					</xsl:when>
					<xsl:when test="mediaobject">
						<xsl:apply-templates select="mediaobject"/>
					</xsl:when>
					<xsl:when test="alt">
						<xsl:apply-templates select="alt"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="graphic"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="$placement!='before'"><xsl:value-of select="$caption" /></xsl:if>
		<xsl:call-template name="map.end"/>
	</xsl:template>

	<doc:template xmlns="">
		<refpurpose>Process <doc:db>informalequation</doc:db> elements</refpurpose>
		<doc:description>
			<para>
				Formats an untitled, block-style equation.
			</para>
		</doc:description>
		<doc:variables>
			<itemizedlist>
				<listitem><simpara><xref linkend="param.latex.alt.is.preferred"/></simpara></listitem>
			</itemizedlist>
		</doc:variables>
		<doc:notes>
			<para>

				The <quote>equation</quote> will be found by searching the
				<sgmltag>informalequation</sgmltag> for its <quote>most
				appropriate</quote> child elements. Firstly, this template will
				search for all <doc:db>alt</doc:db>, <doc:db
				basename="textobject">mediaobject/textobject</doc:db> or
				<doc:db
				basename="phrase">mediaobject/textobject/phrase</doc:db>
				children that have a &roleattr; of <quote>latex</quote> or
				<quote>tex</quote>. If none were found, the template will
				search for generic <doc:db>mediaobject</doc:db> or
				<doc:db>alt</doc:db> children. If <xref
				linkend="param.latex.alt.is.preferred"/> is set, <sgmltag
				basename="alt">alts</sgmltag> will be preferred over <sgmltag
				basename="mediaobject">mediaobjects</sgmltag>. If none of these
				elements was found, the template will format any
				<doc:db>graphic</doc:db> children.

			</para>
		</doc:notes>
		<doc:samples>
			<simplelist type='inline'>
				&test_book;
				<!--
				&test_pavlov;
				-->
			</simplelist>
		</doc:samples>
		<doc:seealso>
			<itemizedlist>
				<listitem><simpara>&mapping;</simpara></listitem>
			</itemizedlist>
		</doc:seealso>
	</doc:template>
	<xsl:template match="informalequation">
		<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']"/>
		<xsl:text>&#10;</xsl:text>
		<xsl:choose>
			<xsl:when test="$tex">
				<xsl:apply-templates select="$tex"/>
			</xsl:when>
			<xsl:when test="alt and $latex.alt.is.preferred='1'">
				<xsl:apply-templates select="alt"/>
			</xsl:when>
			<xsl:when test="mediaobject">
				<xsl:apply-templates select="mediaobject"/>
			</xsl:when>
			<xsl:when test="alt">
				<xsl:apply-templates select="alt"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="graphic"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:text>&#10;&#10;</xsl:text>
	</xsl:template>

</xsl:stylesheet>