]> matita.cs.unibo.it Git - helm.git/blob - helm/style/html_init.xsl
Modified Files:
[helm.git] / helm / style / html_init.xsl
1 <?xml version="1.0"?>
2
3 <!-- Copyright (C) 2000, HELM Team                                     -->
4 <!--                                                                   -->
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.                         -->
8 <!--                                                                   -->
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.            -->
13 <!--                                                                   -->
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.                      -->
18 <!--                                                                   -->
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.                                              -->
23 <!--                                                                   -->
24 <!-- For details, see the HELM World-Wide-Web page,                    -->
25 <!-- http://cs.unibo.it/helm/.                                         -->
26
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">
29
30 <!--***********************************************************************--> 
31 <!-- INIT style for HTML                                                   -->
32 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
33 <!--***********************************************************************--> 
34
35 <!-- BASIC OPERATORS -->
36
37  <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
38        |m:geq|m:gt|m:plus|m:times]">
39   <xsl:param name="current_indent" select="0"/> 
40   <xsl:param name="width" select="$framewidth"/>
41   <xsl:variable name="uri">
42    <xsl:value-of select="*[1]/@definitionURL"/>
43   </xsl:variable>
44   <xsl:variable name="charlength">
45    <xsl:apply-templates select="*[1]" mode="charcount"/>
46   </xsl:variable>
47   <xsl:variable name="symbol">
48    <xsl:choose>
49     <xsl:when test="m:and">
50      <xsl:value-of select="'&#217;'"/>
51     </xsl:when>
52     <xsl:when test="m:or">
53      <xsl:value-of select="'&#218;'"/>
54     </xsl:when>
55     <xsl:when test="m:eq">
56      <xsl:value-of select="'&#61;'"/>
57     </xsl:when>
58     <xsl:when test="m:neq">
59      <xsl:value-of select="'&#185;'"/>
60     </xsl:when>
61     <xsl:when test="m:leq">
62      <xsl:value-of select="'&#163;'"/>
63     </xsl:when>
64     <xsl:when test="m:lt">
65      <xsl:value-of select="'&#60;'"/>
66     </xsl:when>
67     <xsl:when test="m:geq">
68      <xsl:value-of select="'&#179;'"/>
69     </xsl:when>
70     <xsl:when test="m:gt">
71      <xsl:value-of select="'&#62;'"/>
72     </xsl:when>
73     <xsl:when test="m:plus">
74      <xsl:value-of select="'&#43;'"/>
75     </xsl:when>
76     <xsl:when test="m:times">
77      <xsl:value-of select="'&#42;'"/>
78     </xsl:when>
79    </xsl:choose>
80   </xsl:variable>
81   <xsl:choose>
82     <xsl:when test="$charlength > $framewidth">
83      <xsl:text>(</xsl:text>
84      <xsl:apply-templates select="*[2]">
85       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
86      </xsl:apply-templates>
87      <BR/> 
88      <xsl:call-template name="make_indent">
89       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
90      </xsl:call-template>
91      <a>
92      <xsl:attribute name="href">
93       <xsl:value-of select="concat(string($header),string($uri))"/>
94      </xsl:attribute>
95      <FONT FACE="symbol" mathcolor="blue">
96       <xsl:value-of select="$symbol"/>
97      </FONT>
98      </a>
99      <xsl:apply-templates select="*[3]">
100       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
101      </xsl:apply-templates>
102      <xsl:text>)</xsl:text>
103     </xsl:when>
104     <xsl:otherwise>
105      <xsl:text>(</xsl:text>
106      <xsl:apply-templates select="*[2]"/>
107      <a>
108      <xsl:attribute name="href">
109       <xsl:value-of select="concat(string($header),string($uri))"/>
110      </xsl:attribute>
111      <FONT FACE="symbol" mathcolor="blue">
112      <xsl:value-of select="$symbol"/>
113      </FONT>
114      </a>
115      <xsl:apply-templates select="*[3]"/>
116      <xsl:text>)</xsl:text>
117     </xsl:otherwise>
118    </xsl:choose>
119  </xsl:template>
120
121 <!-- MINUS (can be unary!) -->
122
123 <xsl:template match="m:apply[m:minus]">
124   <xsl:param name="current_indent" select="0"/> 
125   <xsl:param name="width" select="$framewidth"/>
126   <xsl:variable name="uri">
127    <xsl:value-of select="*[1]/@definitionURL"/>
128   </xsl:variable>
129   <xsl:choose>
130    <xsl:when test="count(child::*)=2">
131     <a>
132     <xsl:attribute name="href">
133      <xsl:value-of select="concat(string($header),string($uri))"/>
134     </xsl:attribute>
135     <xsl:text>-</xsl:text>
136     </a>
137     <xsl:apply-templates select="*[2]">
138      <xsl:with-param name="current_indent" select="$current_indent + 1"/>
139     </xsl:apply-templates>
140    </xsl:when>
141    <xsl:otherwise>
142     <xsl:variable name="charlength">
143      <xsl:apply-templates select="*[1]" mode="charcount"/>
144     </xsl:variable>
145     <xsl:choose>
146      <xsl:when test="$charlength > $framewidth">
147       <xsl:text>(</xsl:text>
148       <xsl:apply-templates select="*[2]">
149        <xsl:with-param name="current_indent" select="$current_indent + 2"/>
150       </xsl:apply-templates>
151       <BR/> 
152       <xsl:call-template name="make_indent">
153        <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
154       </xsl:call-template>
155       <a>
156       <xsl:attribute name="href">
157        <xsl:value-of select="concat(string($header),string($uri))"/>
158       </xsl:attribute>
159       <xsl:text>-</xsl:text>
160       </a>
161       <xsl:apply-templates select="*[3]">
162        <xsl:with-param name="current_indent" select="$current_indent + 2"/>
163       </xsl:apply-templates>
164       <xsl:text>)</xsl:text>
165      </xsl:when>
166      <xsl:otherwise>
167       <xsl:text>(</xsl:text>
168       <xsl:apply-templates select="*[2]"/>
169       <a>
170       <xsl:attribute name="href">
171        <xsl:value-of select="concat(string($header),string($uri))"/>
172       </xsl:attribute>
173       <xsl:text>-</xsl:text>
174       </a>
175       <xsl:apply-templates select="*[3]"/>
176       <xsl:text>)</xsl:text>
177      </xsl:otherwise>
178     </xsl:choose>
179    </xsl:otherwise>
180   </xsl:choose>
181  </xsl:template>
182
183 <!-- NOT -->
184
185  <xsl:template match="m:apply[m:not]">
186   <xsl:param name="current_indent" select="0"/> 
187   <xsl:param name="width" select="$framewidth"/>
188   <xsl:variable name="uri">
189    <xsl:value-of select="m:not/@definitionURL"/>
190   </xsl:variable>
191      <a>
192      <xsl:attribute name="href">
193       <xsl:value-of select="concat(string($header),string($uri))"/>
194      </xsl:attribute>
195      <FONT FACE="symbol" mathcolor="blue">&#216;</FONT>
196      </a>
197      <xsl:apply-templates select="*[2]"/>
198  </xsl:template>
199
200 <!-- EXISTS -->
201
202  <xsl:template match="m:apply[m:exists]">
203   <xsl:param name="current_indent" select="0"/> 
204   <xsl:param name="width" select="$framewidth"/>
205   <xsl:variable name="uri">
206    <xsl:value-of select="m:exists/@definitionURL"/>
207   </xsl:variable>
208   <xsl:variable name="charlength">
209    <xsl:apply-templates select="m:exists" mode="charcount"/>
210   </xsl:variable>
211   <xsl:choose>
212     <xsl:when test="$charlength > $framewidth">
213      <a>
214      <xsl:attribute name="href">
215       <xsl:value-of select="concat(string($header),string($uri))"/>
216      </xsl:attribute>
217      <FONT FACE="symbol" mathcolor="blue">&#36;</FONT>
218      </a>
219      <xsl:apply-templates select="m:bvar/m:ci"/>
220      <xsl:text>:</xsl:text>
221      <xsl:apply-templates select="m:condition">
222       <xsl:with-param name="current_indent" select="$current_indent + 2 +
223                                 string-length(bvar/ci)"/> 
224      </xsl:apply-templates>
225      <BR/> 
226       <xsl:call-template name="make_indent">
227        <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
228       </xsl:call-template>
229      <xsl:text>.</xsl:text>
230       <xsl:apply-templates select="*[last()]">
231        <xsl:with-param name="current_indent" select="$current_indent + 2"/>
232       </xsl:apply-templates>
233     </xsl:when>
234     <xsl:otherwise>
235      <a>
236      <xsl:attribute name="href">
237       <xsl:value-of select="concat(string($header),string($uri))"/>
238      </xsl:attribute>
239      <FONT FACE="symbol" mathcolor="blue">&#36;</FONT>
240      </a>
241      <xsl:apply-templates select="m:bvar/m:ci"/>
242      <xsl:text>:</xsl:text>
243      <xsl:apply-templates select="m:condition"/>
244      <xsl:text>.</xsl:text>
245      <xsl:apply-templates select="*[last()]">
246       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
247      </xsl:apply-templates>
248     </xsl:otherwise>
249    </xsl:choose>
250  </xsl:template>
251
252
253
254
255 <!-- COUNTING -->
256
257 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:neq
258    |m:lt|m:leq|m:gt|m:geq|m:plus|m:minus|m:times" mode="charcount">
259 <xsl:param name="incurrent_length" select="0"/> 
260     <xsl:choose>
261     <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
262      <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>
263      <xsl:choose>
264      <xsl:when test="string($siblength) = &quot;&quot;">
265       <xsl:value-of select="$incurrent_length + string-length()"/>
266      </xsl:when>
267      <xsl:otherwise>
268       <xsl:value-of select="number($siblength)"/>
269      </xsl:otherwise>
270      </xsl:choose>
271     </xsl:when>
272     <xsl:otherwise>
273      <xsl:value-of select="$incurrent_length + string-length()"/>
274     </xsl:otherwise>
275     </xsl:choose>
276 </xsl:template> 
277
278 </xsl:stylesheet> 
279
280