3 <!-- Copyright (C) 2000, HELM Team -->
5 <!-- This file is part of HELM, an Hypertextual, Electronic -->
6 <!-- Library of Mathematics, developed at the Computer Science -->
7 <!-- Department, University of Bologna, Italy. -->
9 <!-- HELM is free software; you can redistribute it and/or -->
10 <!-- modify it under the terms of the GNU General Public License -->
11 <!-- as published by the Free Software Foundation; either version 2 -->
12 <!-- of the License, or (at your option) any later version. -->
14 <!-- HELM is distributed in the hope that it will be useful, -->
15 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
16 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
17 <!-- GNU General Public License for more details. -->
19 <!-- You should have received a copy of the GNU General Public License -->
20 <!-- along with HELM; if not, write to the Free Software -->
21 <!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, -->
22 <!-- MA 02111-1307, USA. -->
24 <!-- For details, see the HELM World-Wide-Web page, -->
25 <!-- http://cs.unibo.it/helm/. -->
27 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28 xmlns:m="http://www.w3.org/1998/Math/MathML">
30 <xsl:template name="mksymbol-init">
31 <xsl:param name="symbol" select="''"/>
33 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">
34 <xsl:variable name="fontsymbol">
36 <xsl:when test="$symbol = 'and'">
37 <xsl:value-of select="'Ù'"/>
39 <xsl:when test="$symbol = 'or'">
40 <xsl:value-of select="'Ú'"/>
42 <xsl:when test="$symbol = 'eq'">
43 <xsl:value-of select="'='"/>
45 <xsl:when test="$symbol = 'neq'">
46 <xsl:value-of select="'¹'"/>
48 <xsl:when test="$symbol = 'leq'">
49 <xsl:value-of select="'£'"/>
51 <xsl:when test="$symbol = 'lt'">
52 <xsl:value-of select="'<'"/>
54 <xsl:when test="$symbol = 'geq'">
55 <xsl:value-of select="'³'"/>
57 <xsl:when test="$symbol = 'gt'">
58 <xsl:value-of select="'>'"/>
60 <xsl:when test="$symbol = 'plus'">
61 <xsl:value-of select="'+'"/>
63 <xsl:when test="$symbol = 'times'">
64 <xsl:value-of select="'*'"/>
66 <xsl:when test="$symbol = 'minus'">
67 <xsl:value-of select="'-'"/>
69 <xsl:when test="$symbol = 'not'">
70 <xsl:value-of select="'Ø'"/>
72 <xsl:when test="$symbol = 'exists'">
73 <xsl:value-of select="'$'"/>
76 <xsl:text>???</xsl:text>
80 <FONT FACE="symbol" color="'blue'">
81 <xsl:value-of select="$fontsymbol"/>
85 <xsl:variable name="unicodesymbol">
87 <xsl:when test="$symbol = 'and'">
88 <xsl:value-of select="'∧'"/>
90 <xsl:when test="$symbol = 'or'">
91 <xsl:value-of select="'∨'"/>
93 <xsl:when test="$symbol = 'eq'">
94 <xsl:value-of select="'='"/>
96 <xsl:when test="$symbol = 'neq'">
97 <xsl:value-of select="'≠'"/>
99 <xsl:when test="$symbol = 'leq'">
100 <xsl:value-of select="'≤'"/>
102 <xsl:when test="$symbol = 'lt'">
103 <xsl:value-of select="'< '"/>
105 <xsl:when test="$symbol = 'geq'">
106 <xsl:value-of select="'≥'"/>
108 <xsl:when test="$symbol = 'gt'">
109 <xsl:value-of select="'>'"/>
111 <xsl:when test="$symbol = 'plus'">
112 <xsl:value-of select="'+'"/>
114 <xsl:when test="$symbol = 'times'">
115 <xsl:value-of select="'∗'"/>
117 <xsl:when test="$symbol = 'minus'">
118 <xsl:value-of select="'−'"/>
120 <xsl:when test="$symbol = 'not'">
121 <xsl:value-of select="'¬'"/>
123 <xsl:when test="$symbol = 'exists'">
124 <xsl:value-of select="'∃'"/>
127 <xsl:text>???</xsl:text>
131 <FONT color="'blue'">
132 <xsl:value-of select="$unicodesymbol"/>
139 <!--***********************************************************************-->
140 <!-- INIT style for HTML -->
141 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
142 <!--***********************************************************************-->
144 <!-- INLINE MODE : BASIC OPERATORS -->
146 <xsl:template mode="inline" match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
147 |m:geq|m:gt|m:plus|m:times]">
148 <xsl:variable name="uri">
149 <xsl:value-of select="*[1]/@definitionURL"/>
151 <xsl:text>(</xsl:text>
152 <xsl:apply-templates mode="inline" select="*[2]"/>
154 <xsl:call-template name="mksymbol-init">
155 <xsl:with-param name="symbol" select="local-name(*[1])"/>
158 <xsl:apply-templates mode="inline" select="*[3]"/>
159 <xsl:text>)</xsl:text>
162 <!-- INLINE MODE - MINUS (can be unary!) -->
164 <xsl:template mode="inline" match="m:apply[m:minus]">
165 <xsl:variable name="uri">
166 <xsl:value-of select="*[1]/@definitionURL"/>
169 <xsl:when test="count(child::*)=2">
171 <xsl:call-template name="mksymbol-init">
172 <xsl:with-param name="symbol" select="'minus'"/>
175 <xsl:apply-templates mode="inline" select="*[2]"/>
178 <xsl:text>(</xsl:text>
179 <xsl:apply-templates mode="inline" select="*[2]"/>
181 <xsl:call-template name="mksymbol-init">
182 <xsl:with-param name="symbol" select="'minus'"/>
185 <xsl:apply-templates mode="inline" select="*[3]"/>
186 <xsl:text>)</xsl:text>
191 <!-- INLINE MODE NOT -->
193 <xsl:template mode="inline" match="m:apply[m:not]">
194 <xsl:variable name="uri">
195 <xsl:value-of select="m:not/@definitionURL"/>
198 <xsl:call-template name="mksymbol-init">
199 <xsl:with-param name="symbol" select="'not'"/>
202 <xsl:apply-templates mode="inline" select="*[2]"/>
205 <!-- INLINE MODE EXISTS -->
207 <xsl:template mode="inline" match="m:apply[m:exists]">
208 <xsl:variable name="uri">
209 <xsl:value-of select="m:exists/@definitionURL"/>
212 <xsl:call-template name="mksymbol-init">
213 <xsl:with-param name="symbol" select="'exists'"/>
216 <xsl:apply-templates select="m:bvar/m:ci"/>
217 <xsl:text>:</xsl:text>
218 <xsl:apply-templates mode="inline" select="m:condition"/>
219 <xsl:text>.</xsl:text>
220 <xsl:apply-templates mode="inline" select="*[last()]"/>
223 <!-- COUNTING MODE -->
225 <!-- BASIC OPERATORS -->
227 <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
228 |m:geq|m:gt|m:plus|m:times]">
229 <xsl:param name="current_indent" select="0"/>
230 <xsl:param name="width" select="$framewidth"/>
231 <xsl:variable name="uri">
232 <xsl:value-of select="*[1]/@definitionURL"/>
234 <xsl:variable name="charlength">
235 <xsl:apply-templates select="*[1]" mode="charcount"/>
238 <xsl:when test="$charlength > $framewidth">
239 <xsl:text>(</xsl:text>
240 <xsl:apply-templates select="*[2]">
241 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
242 </xsl:apply-templates>
244 <xsl:call-template name="make_indent">
245 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
248 <xsl:call-template name="mksymbol-init">
249 <xsl:with-param name="symbol" select="local-name(*[1])"/>
252 <xsl:apply-templates select="*[3]">
253 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
254 </xsl:apply-templates>
255 <xsl:text>)</xsl:text>
258 <xsl:apply-templates mode="inline" select="."/>
263 <!-- MINUS (can be unary!) -->
265 <xsl:template match="m:apply[m:minus]">
266 <xsl:param name="current_indent" select="0"/>
267 <xsl:param name="width" select="$framewidth"/>
268 <xsl:variable name="uri">
269 <xsl:value-of select="*[1]/@definitionURL"/>
272 <xsl:when test="count(child::*)=2">
274 <xsl:call-template name="mksymbol-init">
275 <xsl:with-param name="symbol" select="'minus'"/>
278 <xsl:apply-templates select="*[2]">
279 <xsl:with-param name="current_indent" select="$current_indent + 1"/>
280 </xsl:apply-templates>
283 <xsl:variable name="charlength">
284 <xsl:apply-templates select="*[1]" mode="charcount"/>
287 <xsl:when test="$charlength > $framewidth">
288 <xsl:text>(</xsl:text>
289 <xsl:apply-templates select="*[2]">
290 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
291 </xsl:apply-templates>
293 <xsl:call-template name="make_indent">
294 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
297 <xsl:call-template name="mksymbol-init">
298 <xsl:with-param name="symbol" select="'minus'"/>
301 <xsl:apply-templates select="*[3]">
302 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
303 </xsl:apply-templates>
304 <xsl:text>)</xsl:text>
307 <xsl:apply-templates mode="inline" select="."/>
316 <xsl:template match="m:apply[m:not]">
317 <xsl:param name="current_indent" select="0"/>
318 <xsl:param name="width" select="$framewidth"/>
319 <xsl:variable name="uri">
320 <xsl:value-of select="m:not/@definitionURL"/>
323 <xsl:call-template name="mksymbol-init">
324 <xsl:with-param name="symbol" select="'not'"/>
327 <xsl:apply-templates select="*[2]"/>
332 <xsl:template match="m:apply[m:exists]">
333 <xsl:param name="current_indent" select="0"/>
334 <xsl:param name="width" select="$framewidth"/>
335 <xsl:variable name="uri">
336 <xsl:value-of select="m:exists/@definitionURL"/>
338 <xsl:variable name="charlength">
339 <xsl:apply-templates select="m:exists" mode="charcount"/>
342 <xsl:when test="$charlength > $framewidth">
344 <xsl:call-template name="mksymbol-init">
345 <xsl:with-param name="symbol" select="'exists'"/>
348 <xsl:apply-templates select="m:bvar/m:ci"/>
349 <xsl:text>:</xsl:text>
350 <xsl:apply-templates select="m:condition">
351 <xsl:with-param name="current_indent" select="$current_indent + 2 +
352 string-length(bvar/ci)"/>
353 </xsl:apply-templates>
355 <xsl:call-template name="make_indent">
356 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
358 <xsl:text>.</xsl:text>
359 <xsl:apply-templates select="*[last()]">
360 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
361 </xsl:apply-templates>
364 <xsl:apply-templates mode="inline" select="."/>
374 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:neq
375 |m:lt|m:leq|m:gt|m:geq|m:plus|m:minus|m:times" mode="charcount">
376 <xsl:param name="incurrent_length" select="0"/>
378 <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
379 <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
381 <xsl:when test="string($siblength) = """>
382 <xsl:value-of select="$incurrent_length + string-length()"/>
385 <xsl:value-of select="number($siblength)"/>
390 <xsl:value-of select="$incurrent_length + string-length()"/>