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