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