6c3ea3ff551178e4f38c63bd0452bab30cc325de
[abartlet/samba.git/.git] / docs / docbook / xslt / db2latex / formal.mod.xsl
1 <?xml version='1.0'?>
2 <!--############################################################################# 
3 |       $Id: formal.mod.xsl,v 1.1 2003/04/30 21:39:49 ab Exp $
4 |- #############################################################################
5 |       $Author: ab $
6 |                                                                                                               
7 |   PURPOSE:
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
15
16     <!--############################################################################# -->
17     <!-- DOCUMENTATION                                                                -->
18     <doc:reference id="formal" xmlns="">
19         <referenceinfo>
20             <releaseinfo role="meta">
21                 $Id: formal.mod.xsl,v 1.1 2003/04/30 21:39:49 ab Exp $
22             </releaseinfo>
23         <authorgroup>
24             <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
25             <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
26         </authorgroup>
27             <copyright>
28                 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
29                 <holder>Ramon Casellas</holder>
30             </copyright>
31         </referenceinfo>
32
33         <title>Formal Objects <filename>formal.mod.xsl</filename></title>
34         <partintro>
35             <section><title>Introduction</title>
36                 <para></para>
37             </section>
38         </partintro>
39     </doc:reference>
40
41
42
43
44     <xsl:template name="formal.object">
45         <xsl:call-template name="formal.object.heading">
46             <xsl:with-param name="title"><xsl:apply-templates select="." mode="title.ref"/></xsl:with-param>
47         </xsl:call-template>
48         <xsl:apply-templates/>
49     </xsl:template>
50
51     <xsl:template name="formal.object.heading">
52         <xsl:param name="title"></xsl:param>
53         <xsl:call-template name="label.id"/>
54         <xsl:copy-of select="$title"/>
55     </xsl:template>
56
57     <xsl:template name="informal.object">
58         <xsl:call-template name="label.id"/>
59         <xsl:apply-templates/>
60     </xsl:template>
61
62     <xsl:template name="semiformal.object">
63         <xsl:choose>
64             <xsl:when test="title">     <xsl:call-template name="formal.object"/>       </xsl:when>
65             <xsl:otherwise> <xsl:call-template name="informal.object"/></xsl:otherwise>
66         </xsl:choose>
67     </xsl:template>
68
69
70         <xsl:template name="generate.formal.title.placement">
71                 <xsl:param name="object" select="figure" />
72                 <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement),concat($object, ' '))"/>
73                 <xsl:choose>
74                         <xsl:when test="contains($param.placement, ' ')">
75                                 <xsl:value-of select="substring-before($param.placement, ' ')"/>
76                         </xsl:when>
77                         <xsl:when test="$param.placement = ''">before</xsl:when>
78                         <xsl:otherwise>
79                                 <xsl:value-of select="$param.placement"/>
80                         </xsl:otherwise>
81                 </xsl:choose>
82         </xsl:template>
83
84
85
86
87 <!-- ========================================  -->
88 <!-- XSL Template for DocBook Equation Element -->
89 <!-- 2003/07/04 Applied patches from J.Pavlovic -->
90 <!-- ========================================  -->
91 <xsl:template match="equation">
92 <!-- Equation title placement -->
93 <xsl:variable name="placement">
94         <xsl:call-template name="generate.formal.title.placement">
95                 <xsl:with-param name="object" select="local-name(.)" />
96         </xsl:call-template>
97 </xsl:variable>
98 <!-- Equation caption -->
99 <xsl:variable name="caption">
100         <xsl:text>\caption{</xsl:text>
101         <xsl:apply-templates select="title" mode="caption.mode"/>
102         <xsl:text>}&#10;</xsl:text>
103 </xsl:variable>
104 <xsl:call-template name="map.begin"/>
105 <xsl:if test="$placement='before'">
106         <xsl:text>\captionswapskip{}</xsl:text>
107         <xsl:value-of select="$caption" />
108         <xsl:text>\captionswapskip{}</xsl:text>
109 </xsl:if>
110 <xsl:choose>
111         <xsl:when test="informalequation">
112                 <xsl:apply-templates select="informalequation"/>
113         </xsl:when>
114         <xsl:otherwise>
115                 <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']"/>
116                 <xsl:choose>
117                         <xsl:when test="$tex">
118                                 <xsl:apply-templates select="$tex"/>
119                         </xsl:when>
120                         <xsl:when test="alt and $latex.alt.is.preferred='1'">
121                                 <xsl:apply-templates select="alt"/>
122                         </xsl:when>
123                         <xsl:when test="mediaobject">
124                                 <xsl:apply-templates select="mediaobject"/>
125                         </xsl:when>
126                         <xsl:when test="alt">
127                                 <xsl:apply-templates select="alt"/>
128                         </xsl:when>
129                         <xsl:otherwise>
130                                 <xsl:apply-templates select="graphic"/>
131                         </xsl:otherwise>
132                 </xsl:choose>
133         </xsl:otherwise>
134 </xsl:choose>
135 <xsl:if test="$placement!='before'"><xsl:value-of select="$caption" /></xsl:if>
136 <xsl:call-template name="map.end"/>
137 </xsl:template>
138
139
140 <xsl:template match="equation/title"/>
141
142
143
144
145
146 <xsl:template match="informalequation">
147 <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']"/>
148 <xsl:text>&#10;</xsl:text>
149 <xsl:choose>
150         <xsl:when test="$tex">
151                 <xsl:apply-templates select="$tex"/>
152         </xsl:when>
153         <xsl:when test="alt and $latex.alt.is.preferred='1'">
154                 <xsl:apply-templates select="alt"/>
155         </xsl:when>
156         <xsl:when test="mediaobject">
157                 <xsl:apply-templates select="mediaobject"/>
158         </xsl:when>
159         <xsl:when test="alt">
160                 <xsl:apply-templates select="alt"/>
161         </xsl:when>
162         <xsl:otherwise>
163                 <xsl:apply-templates select="graphic"/>
164         </xsl:otherwise>
165 </xsl:choose>
166 <xsl:text>&#10;&#10;</xsl:text>
167 </xsl:template>
168
169
170
171
172
173
174
175
176 </xsl:stylesheet>