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 + ############################################################################## -->
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'>
13 <doc:reference id="formal" xmlns="">
15 <releaseinfo role="meta">
16 $Id: formal.mod.xsl,v 1.13 2004/01/03 09:48:34 j-devenish Exp $
23 <year>2000</year><year>2001</year><year>2002</year><year>2003</year>
24 <holder>Ramon Casellas</holder>
27 <doc:revision rcasver="1.10">&rev_2003_05;</doc:revision>
30 <title>Formal Objects <filename>formal.mod.xsl</filename></title>
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)
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>
42 <doc:template xmlns="">
43 <refpurpose> Typeset a formal object generically </refpurpose>
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"/>.
56 <listitem><simpara><xref linkend="template.formal.object.title"/></simpara></listitem>
57 <listitem><simpara><xref linkend="template.content-templates"/></simpara></listitem>
61 <xsl:template name="formal.object">
62 <xsl:call-template name="formal.object.title"/>
63 <xsl:call-template name="content-templates"/>
66 <doc:template xmlns="">
67 <refpurpose> Typeset the title of a formal object generically </refpurpose>
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>)
81 <xsl:template name="formal.object.title">
82 <xsl:param name="title">
83 <xsl:apply-templates select="." mode="title.content"/>
85 <xsl:call-template name="label.id"/>
86 <xsl:copy-of select="$title"/>
89 <doc:template xmlns="">
90 <refpurpose> Typeset an informal object generically </refpurpose>
94 Outputs an anchor for cross-references and hyper-links, then
95 applies all templates.
103 <xsl:template name="informal.object">
104 <xsl:call-template name="label.id"/>
105 <xsl:apply-templates/>
108 <doc:template xmlns="">
109 <refpurpose> Typeset formal or informal object generically </refpurpose>
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"/>.
124 <xsl:template name="semiformal.object">
126 <xsl:when test="title"><xsl:call-template name="formal.object"/></xsl:when>
127 <xsl:otherwise><xsl:call-template name="informal.object"/></xsl:otherwise>
131 <doc:template xmlns="">
132 <refpurpose> Determine the relative position for a <doc:db>caption</doc:db> </refpurpose>
135 Chooses the position of a caption to be <quote>before</quote>
136 or <quote>after</quote> the selected object.
141 <listitem><simpara><xref linkend="param.formal.title.placement"/></simpara></listitem>
151 The type of object (i.e. name of the element) to which the caption pertains.
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.
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, ' '))"/>
172 <xsl:when test="contains($param.placement, ' ')">
173 <xsl:value-of select="substring-before($param.placement, ' ')"/>
175 <xsl:when test="$param.placement = ''">before</xsl:when>
177 <xsl:value-of select="$param.placement"/>
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>
190 Formats an titled, block-style equation.
195 <listitem><simpara><xref linkend="param.latex.equation.caption.style"/></simpara></listitem>
196 <listitem><simpara><xref linkend="param.latex.alt.is.preferred"/></simpara></listitem>
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.
210 <simplelist type='inline'>
216 <listitem><simpara>&mapping;</simpara></listitem>
217 <listitem><simpara><xref linkend="template.generate.formal.title.placement"/></simpara></listitem>
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(.)" />
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>}} </xsl:text>
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>
245 <xsl:when test="informalequation">
246 <xsl:apply-templates select="informalequation"/>
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']"/>
251 <xsl:when test="$tex">
252 <xsl:apply-templates select="$tex"/>
254 <xsl:when test="alt and $latex.alt.is.preferred='1'">
255 <xsl:apply-templates select="alt"/>
257 <xsl:when test="mediaobject">
258 <xsl:apply-templates select="mediaobject"/>
260 <xsl:when test="alt">
261 <xsl:apply-templates select="alt"/>
264 <xsl:apply-templates select="graphic"/>
269 <xsl:if test="$placement!='before'"><xsl:value-of select="$caption" /></xsl:if>
270 <xsl:call-template name="map.end"/>
273 <doc:template xmlns="">
274 <refpurpose>Process <doc:db>informalequation</doc:db> elements</refpurpose>
277 Formats an untitled, block-style equation.
282 <listitem><simpara><xref linkend="param.latex.alt.is.preferred"/></simpara></listitem>
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
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.
308 <simplelist type='inline'>
317 <listitem><simpara>&mapping;</simpara></listitem>
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> </xsl:text>
325 <xsl:when test="$tex">
326 <xsl:apply-templates select="$tex"/>
328 <xsl:when test="alt and $latex.alt.is.preferred='1'">
329 <xsl:apply-templates select="alt"/>
331 <xsl:when test="mediaobject">
332 <xsl:apply-templates select="mediaobject"/>
334 <xsl:when test="alt">
335 <xsl:apply-templates select="alt"/>
338 <xsl:apply-templates select="graphic"/>
341 <xsl:text> </xsl:text>