~pythoneers/ubuntu/lucid/feedparser/ltsppa

« back to all changes in this revision

Viewing changes to docs/docbook/xsl/html/math.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Galisteo
  • Date: 2007-01-09 15:27:45 UTC
  • mfrom: (2.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20070109152745-pg3zhn67yyaumwv3
Tags: 4.1-7
Fixed css link for *.html inside /doc. (Closes: #405343)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version='1.0'?>
2
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
 
                version='1.0'>
4
 
 
5
 
<!-- ********************************************************************
6
 
     $Id: math.xsl,v 1.1.1.1 2004/06/22 02:10:10 f8dy Exp $
7
 
     ********************************************************************
8
 
 
9
 
     This file is part of the XSL DocBook Stylesheet distribution.
10
 
     See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11
 
     and other information.
12
 
 
13
 
     ******************************************************************** -->
14
 
 
15
 
<xsl:template match="inlineequation">
16
 
  <xsl:apply-templates/>
17
 
</xsl:template>
18
 
 
19
 
<xsl:template match="alt">
20
 
</xsl:template>
21
 
 
22
 
<!-- "Support" for MathML -->
23
 
 
24
 
<xsl:template match="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
25
 
  <xsl:copy>
26
 
    <xsl:copy-of select="@*"/>
27
 
    <xsl:apply-templates/>
28
 
  </xsl:copy>
29
 
</xsl:template>
30
 
 
31
 
<!-- Support for TeX math in alt -->
32
 
 
33
 
<xsl:template match="*" mode="collect.tex.math">
34
 
  <xsl:call-template name="write.text.chunk">
35
 
    <xsl:with-param name="filename" select="$tex.math.file"/>
36
 
    <xsl:with-param name="method" select="'text'"/>
37
 
    <xsl:with-param name="content">
38
 
      <xsl:choose>
39
 
        <xsl:when test="$tex.math.in.alt = 'plain'">
40
 
          <xsl:call-template name="tex.math.plain.head"/>
41
 
          <xsl:apply-templates select="." mode="collect.tex.math.plain"/>
42
 
          <xsl:call-template name="tex.math.plain.tail"/>
43
 
        </xsl:when>
44
 
        <xsl:when test="$tex.math.in.alt = 'latex'">
45
 
          <xsl:call-template name="tex.math.latex.head"/>
46
 
          <xsl:apply-templates select="." mode="collect.tex.math.latex"/>
47
 
          <xsl:call-template name="tex.math.latex.tail"/>
48
 
        </xsl:when>
49
 
        <xsl:otherwise>
50
 
          <xsl:message>
51
 
            Unsupported TeX math notation: 
52
 
            <xsl:value-of select="$tex.math.in.alt"/>
53
 
          </xsl:message>
54
 
        </xsl:otherwise>
55
 
      </xsl:choose>
56
 
    </xsl:with-param>
57
 
    <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
58
 
  </xsl:call-template>
59
 
</xsl:template>
60
 
 
61
 
<!-- PlainTeX -->
62
 
 
63
 
<xsl:template name="tex.math.plain.head">
64
 
  <xsl:text>\nopagenumbers &#xA;</xsl:text>
65
 
</xsl:template>
66
 
 
67
 
<xsl:template name="tex.math.plain.tail">
68
 
  <xsl:text>\bye &#xA;</xsl:text>
69
 
</xsl:template>
70
 
 
71
 
<xsl:template match="inlineequation" mode="collect.tex.math.plain">
72
 
  <xsl:variable name="filename">
73
 
    <xsl:choose>
74
 
      <xsl:when test="graphic">
75
 
        <xsl:call-template name="mediaobject.filename">
76
 
          <xsl:with-param name="object" select="graphic"/>
77
 
        </xsl:call-template>
78
 
      </xsl:when>
79
 
      <xsl:otherwise>
80
 
        <xsl:call-template name="select.mediaobject.filename">
81
 
          <xsl:with-param name="olist" select="inlinemediaobject/*"/>
82
 
        </xsl:call-template>
83
 
      </xsl:otherwise>
84
 
    </xsl:choose>
85
 
  </xsl:variable>
86
 
  <xsl:variable name="output.delims">
87
 
    <xsl:call-template name="tex.math.output.delims"/>
88
 
  </xsl:variable>
89
 
  <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
90
 
  <xsl:if test="$tex">
91
 
    <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
92
 
    <xsl:value-of select="$filename"/>
93
 
    <xsl:text>} &#xA;</xsl:text>
94
 
    <xsl:if test="$output.delims != 0">
95
 
      <xsl:text>$</xsl:text>
96
 
    </xsl:if>
97
 
    <xsl:value-of select="$tex"/>
98
 
    <xsl:if test="$output.delims != 0">
99
 
      <xsl:text>$ &#xA;</xsl:text>
100
 
    </xsl:if>
101
 
    <xsl:text>\vfill\eject &#xA;</xsl:text>
102
 
  </xsl:if>
103
 
</xsl:template>
104
 
 
105
 
<xsl:template match="equation|informalequation" mode="collect.tex.math.plain">
106
 
  <xsl:variable name="filename">
107
 
    <xsl:choose>
108
 
      <xsl:when test="graphic">
109
 
        <xsl:call-template name="mediaobject.filename">
110
 
          <xsl:with-param name="object" select="graphic"/>
111
 
        </xsl:call-template>
112
 
      </xsl:when>
113
 
      <xsl:otherwise>
114
 
        <xsl:call-template name="select.mediaobject.filename">
115
 
          <xsl:with-param name="olist" select="mediaobject/*"/>
116
 
        </xsl:call-template>
117
 
      </xsl:otherwise>
118
 
    </xsl:choose>
119
 
  </xsl:variable>
120
 
  <xsl:variable name="output.delims">
121
 
    <xsl:call-template name="tex.math.output.delims"/>
122
 
  </xsl:variable>
123
 
  <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
124
 
  <xsl:if test="$tex">
125
 
    <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
126
 
    <xsl:value-of select="$filename"/>
127
 
    <xsl:text>} &#xA;</xsl:text>
128
 
    <xsl:if test="$output.delims != 0">
129
 
      <xsl:text>$$</xsl:text>
130
 
    </xsl:if>
131
 
    <xsl:value-of select="$tex"/>
132
 
    <xsl:if test="$output.delims != 0">
133
 
      <xsl:text>$$ &#xA;</xsl:text>
134
 
    </xsl:if>
135
 
    <xsl:text>\vfill\eject &#xA;</xsl:text>
136
 
  </xsl:if>
137
 
</xsl:template>
138
 
 
139
 
<xsl:template match="text()" mode="collect.tex.math.plain"/>
140
 
 
141
 
<!-- LaTeX -->
142
 
 
143
 
<xsl:template name="tex.math.latex.head">
144
 
  <xsl:text>\documentclass{article} &#xA;</xsl:text>
145
 
  <xsl:text>\pagestyle{empty} &#xA;</xsl:text>
146
 
  <xsl:text>\begin{document} &#xA;</xsl:text>
147
 
</xsl:template>
148
 
 
149
 
<xsl:template name="tex.math.latex.tail">
150
 
  <xsl:text>\end{document} &#xA;</xsl:text>
151
 
</xsl:template>
152
 
 
153
 
<xsl:template match="inlineequation" mode="collect.tex.math.latex">
154
 
  <xsl:variable name="filename">
155
 
    <xsl:choose>
156
 
      <xsl:when test="graphic">
157
 
        <xsl:call-template name="mediaobject.filename">
158
 
          <xsl:with-param name="object" select="graphic"/>
159
 
        </xsl:call-template>
160
 
      </xsl:when>
161
 
      <xsl:otherwise>
162
 
        <xsl:call-template name="select.mediaobject.filename">
163
 
          <xsl:with-param name="olist" select="inlinemediaobject/*"/>
164
 
        </xsl:call-template>
165
 
      </xsl:otherwise>
166
 
    </xsl:choose>
167
 
  </xsl:variable>
168
 
  <xsl:variable name="output.delims">
169
 
    <xsl:call-template name="tex.math.output.delims"/>
170
 
  </xsl:variable>
171
 
  <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
172
 
  <xsl:if test="$tex">
173
 
    <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
174
 
    <xsl:value-of select="$filename"/>
175
 
    <xsl:text>} &#xA;</xsl:text>
176
 
    <xsl:if test="$output.delims != 0">  
177
 
      <xsl:text>$</xsl:text>
178
 
    </xsl:if>
179
 
    <xsl:value-of select="$tex"/>
180
 
    <xsl:if test="$output.delims != 0">  
181
 
      <xsl:text>$ &#xA;</xsl:text>
182
 
    </xsl:if>
183
 
    <xsl:text>\newpage &#xA;</xsl:text>
184
 
  </xsl:if>
185
 
</xsl:template>
186
 
 
187
 
<xsl:template match="equation|informalequation" mode="collect.tex.math.latex">
188
 
  <xsl:variable name="filename">
189
 
    <xsl:choose>
190
 
      <xsl:when test="graphic">
191
 
        <xsl:call-template name="mediaobject.filename">
192
 
          <xsl:with-param name="object" select="graphic"/>
193
 
        </xsl:call-template>
194
 
      </xsl:when>
195
 
      <xsl:otherwise>
196
 
        <xsl:call-template name="select.mediaobject.filename">
197
 
          <xsl:with-param name="olist" select="mediaobject/*"/>
198
 
        </xsl:call-template>
199
 
      </xsl:otherwise>
200
 
    </xsl:choose>
201
 
  </xsl:variable>
202
 
  <xsl:variable name="output.delims">
203
 
    <xsl:call-template name="tex.math.output.delims"/>
204
 
  </xsl:variable>
205
 
  <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
206
 
  <xsl:if test="$tex">
207
 
    <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
208
 
    <xsl:value-of select="$filename"/>
209
 
    <xsl:text>} &#xA;</xsl:text>
210
 
    <xsl:if test="$output.delims != 0">
211
 
      <xsl:text>$$</xsl:text>
212
 
    </xsl:if>
213
 
    <xsl:value-of select="$tex"/>
214
 
    <xsl:if test="$output.delims != 0">
215
 
      <xsl:text>$$ &#xA;</xsl:text>
216
 
    </xsl:if>
217
 
    <xsl:text>\newpage &#xA;</xsl:text>
218
 
  </xsl:if>
219
 
</xsl:template>
220
 
 
221
 
<xsl:template match="text()" mode="collect.tex.math.latex"/>
222
 
 
223
 
<!-- Extracting image filename from mediaobject and graphic elements -->
224
 
 
225
 
<xsl:template name="select.mediaobject.filename">
226
 
  <xsl:param name="olist"
227
 
             select="imageobject|imageobjectco
228
 
                     |videoobject|audioobject|textobject"/>
229
 
 
230
 
  <xsl:variable name="mediaobject.index">
231
 
    <xsl:call-template name="select.mediaobject.index">
232
 
      <xsl:with-param name="olist" select="$olist"/>
233
 
      <xsl:with-param name="count" select="1"/>
234
 
    </xsl:call-template>
235
 
  </xsl:variable>
236
 
 
237
 
  <xsl:if test="$mediaobject.index != ''">
238
 
    <xsl:call-template name="mediaobject.filename">
239
 
      <xsl:with-param name="object"
240
 
                      select="$olist[position() = $mediaobject.index]"/>
241
 
    </xsl:call-template>
242
 
  </xsl:if>
243
 
</xsl:template>
244
 
 
245
 
<xsl:template name="tex.math.output.delims">
246
 
  <xsl:variable name="pi.delims">
247
 
    <xsl:call-template name="pi-attribute">
248
 
      <xsl:with-param name="pis" select=".//processing-instruction('dbtex')"/>
249
 
      <xsl:with-param name="attribute" select="'delims'"/>
250
 
    </xsl:call-template>
251
 
  </xsl:variable>
252
 
  <xsl:variable name="result">
253
 
    <xsl:choose>
254
 
      <xsl:when test="$pi.delims = 'no'">0</xsl:when>
255
 
      <xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
256
 
      <xsl:otherwise>1</xsl:otherwise>
257
 
    </xsl:choose>
258
 
  </xsl:variable>
259
 
  <xsl:value-of select="$result"/>
260
 
</xsl:template>
261
 
 
262
 
</xsl:stylesheet>