]> matita.cs.unibo.it Git - helm.git/blob - helm/style/html_set.xsl
Bug fixed: now propagates informations about inner-types usage and
[helm.git] / helm / style / html_set.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 <!-- **************************************************************** -->
36 <!--                   INLINE MODE                                    -->
37 <!-- **************************************************************** -->
38
39 <!-- SET -->
40
41  <xsl:template mode="inline" match="m:set">
42   <xsl:variable name="uri">
43    <xsl:value-of select="concat(string($absPath), @definitionURL)"/>
44   </xsl:variable>
45   <xsl:choose>
46    <xsl:when test="count(child::*) = 0">
47     <FONT FACE="symbol" mathcolor="blue">&#198;</FONT>
48    </xsl:when>
49    <xsl:otherwise>
50     <xsl:choose>
51      <xsl:when test="name(*[1]) = 'm:bvar'">
52       <xsl:text>{</xsl:text>
53       <xsl:apply-templates mode="inline" select="m:bvar/m:ci"/>
54       <xsl:text>:</xsl:text>
55       <xsl:apply-templates mode="inline" select="m:bvar/m:type"/>
56       <xsl:text>|</xsl:text>
57       <xsl:apply-templates mode="inline" select="*[position()=2]"/>
58       <xsl:text>}</xsl:text>
59      </xsl:when>
60      <xsl:otherwise>
61       <xsl:text>{</xsl:text>
62       <xsl:for-each select="*">
63        <xsl:apply-templates mode="inline" select="."/>
64        <xsl:choose>
65         <xsl:when test="position() = last()">
66          <xsl:text>}</xsl:text>
67         </xsl:when>
68         <xsl:otherwise>
69          <xsl:text>,</xsl:text>
70         </xsl:otherwise>
71        </xsl:choose>
72       </xsl:for-each>
73      </xsl:otherwise>
74     </xsl:choose>
75    </xsl:otherwise>
76   </xsl:choose>
77  </xsl:template>
78
79
80 <!-- CARD -->
81 <xsl:template mode="inline" match="m:apply[m:card]">
82   <xsl:param name="current_indent" select="0"/> 
83   <xsl:param name="width" select="$framewidth"/>
84   <xsl:variable name="uri">
85    <xsl:value-of select="m:card/@definitionURL"/>
86   </xsl:variable>
87   <xsl:text>|</xsl:text>
88   <xsl:apply-templates mode="inline" select="*[2]"/>
89   <xsl:text>|</xsl:text>
90  </xsl:template>
91
92 <xsl:template mode="inline" match="m:apply[m:in|m:notin|m:intersect|m:union
93   |m:subset|m:prsubset|m:setdiff]">
94   <xsl:variable name="uri">
95    <xsl:value-of select="*[1]/@definitionURL"/>
96   </xsl:variable>
97   <xsl:variable name="symbol">
98    <xsl:choose>
99     <xsl:when test="m:in">
100      <xsl:value-of select="'&#206;'"/>
101     </xsl:when>
102     <xsl:when test="m:notin">
103      <xsl:value-of select="'&#207;'"/>
104     </xsl:when>
105     <xsl:when test="m:intersect">
106      <xsl:value-of select="'&#199;'"/>
107     </xsl:when>
108     <xsl:when test="m:union">
109      <xsl:value-of select="'&#200;'"/>
110     </xsl:when>
111     <xsl:when test="m:subset">
112      <xsl:value-of select="'&#205;'"/>
113     </xsl:when>
114     <xsl:when test="m:prsubset">
115      <xsl:value-of select="'&#204;'"/>
116     </xsl:when>
117     <xsl:when test="m:setdiff">
118      <xsl:value-of select="'/'"/>
119     </xsl:when>
120    </xsl:choose>
121   </xsl:variable>
122   <xsl:text>(</xsl:text>
123   <xsl:apply-templates mode="inline" select="*[2]"/>
124   <a>
125    <xsl:attribute name="href">
126     <xsl:call-template name="makeURL">
127      <xsl:with-param name="url" select="$uri"/>
128     </xsl:call-template>
129    </xsl:attribute>
130    <FONT FACE="symbol" mathcolor="blue">
131     <xsl:value-of select="$symbol"/>
132    </FONT>
133   </a>
134   <xsl:apply-templates mode="inline" select="*[3]"/>
135   <xsl:text>)</xsl:text>
136  </xsl:template>
137
138 <!-- *************************************************************** -->
139
140 <xsl:template match="m:apply[m:in|m:notin|m:intersect|m:union
141   |m:subset|m:prsubset|m:setdiff]">
142   <xsl:param name="current_indent" select="0"/> 
143   <xsl:param name="width" select="$framewidth"/>
144   <xsl:variable name="uri">
145    <xsl:value-of select="*[1]/@definitionURL"/>
146   </xsl:variable>
147   <xsl:variable name="charlength">
148    <xsl:apply-templates select="*[1]" mode="charcount"/>
149   </xsl:variable>
150   <xsl:variable name="symbol">
151    <xsl:choose>
152     <xsl:when test="m:in">
153      <xsl:value-of select="'&#206;'"/>
154     </xsl:when>
155     <xsl:when test="m:notin">
156      <xsl:value-of select="'&#207;'"/>
157     </xsl:when>
158     <xsl:when test="m:intersect">
159      <xsl:value-of select="'&#199;'"/>
160     </xsl:when>
161     <xsl:when test="m:union">
162      <xsl:value-of select="'&#200;'"/>
163     </xsl:when>
164     <xsl:when test="m:subset">
165      <xsl:value-of select="'&#205;'"/>
166     </xsl:when>
167     <xsl:when test="m:prsubset">
168      <xsl:value-of select="'&#204;'"/>
169     </xsl:when>
170     <xsl:when test="m:setdiff">
171      <xsl:value-of select="'/'"/>
172     </xsl:when>
173    </xsl:choose>
174   </xsl:variable>
175   <xsl:choose>
176     <xsl:when test="$charlength > $framewidth">
177      <xsl:text>(</xsl:text>
178      <xsl:apply-templates select="*[2]">
179       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
180      </xsl:apply-templates>
181      <BR/> 
182      <xsl:call-template name="make_indent">
183       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
184      </xsl:call-template>
185      <a>
186      <xsl:attribute name="href">
187       <xsl:call-template name="makeURL">
188        <xsl:with-param name="url" select="$uri"/>
189       </xsl:call-template>
190      </xsl:attribute>
191      <FONT FACE="symbol" mathcolor="blue">
192       <xsl:value-of select="$symbol"/>
193      </FONT>
194      </a>
195      <xsl:apply-templates select="*[3]">
196       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
197      </xsl:apply-templates>
198      <xsl:text>)</xsl:text>
199     </xsl:when>
200     <xsl:otherwise>
201      <xsl:apply-templates mode="inline" select="."/>
202     </xsl:otherwise>
203    </xsl:choose>
204  </xsl:template>
205
206
207 <!-- SET -->
208
209  <xsl:template match="m:set">
210   <xsl:param name="current_indent" select="0"/> 
211   <xsl:param name="width" select="$framewidth"/>
212   <xsl:variable name="uri">
213    <xsl:value-of select="concat(string($absPath), @definitionURL)"/>
214   </xsl:variable>
215   <xsl:choose>
216    <xsl:when test="count(child::*) = 0">
217     <FONT FACE="symbol" mathcolor="blue">&#198;</FONT>
218    </xsl:when>
219    <xsl:otherwise>
220     <xsl:variable name="charlength">
221      <xsl:apply-templates select="." mode="charcount"/>
222     </xsl:variable>
223     <xsl:choose>
224      <xsl:when test="$charlength > $framewidth">
225       <xsl:choose>
226        <xsl:when test="name(*[1]) = 'm:bvar'">
227         <xsl:text>{</xsl:text>
228         <xsl:apply-templates select="m:bvar/m:ci"/>
229         <xsl:text>:</xsl:text>
230         <xsl:apply-templates select="m:bvar/m:type">
231          <xsl:with-param name="current_indent" 
232            select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
233         </xsl:apply-templates><BR/>
234         <xsl:call-template name="make_indent">
235          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
236         </xsl:call-template>
237         <xsl:text>|</xsl:text>
238         <xsl:apply-templates select="m:condition">
239          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
240         </xsl:apply-templates>
241         <xsl:text>}</xsl:text>
242        </xsl:when>
243        <xsl:otherwise>
244         <xsl:text>{</xsl:text>
245          <xsl:apply-templates select="*[position()=1]">
246           <xsl:with-param name="current_indent" select="$current_indent + 2"/>
247          </xsl:apply-templates>
248          <xsl:for-each select="*[position()>1]">
249           <xsl:text>,</xsl:text>
250           <BR/>
251           <xsl:call-template name="make_indent">
252            <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
253           </xsl:call-template>
254           <xsl:apply-templates select=".">
255            <xsl:with-param name="current_indent" select="$current_indent + 2"/>
256           </xsl:apply-templates>
257          </xsl:for-each>
258         <xsl:text>}</xsl:text>
259        </xsl:otherwise>
260       </xsl:choose>
261      </xsl:when>
262      <xsl:otherwise>
263       <xsl:apply-templates mode="inline" select="."/>
264      </xsl:otherwise>
265     </xsl:choose>
266    </xsl:otherwise>
267   </xsl:choose>
268  </xsl:template> 
269
270 <!-- CARD -->
271 <xsl:template match="m:apply[m:card]">
272   <xsl:param name="current_indent" select="0"/> 
273   <xsl:param name="width" select="$framewidth"/>
274   <xsl:variable name="uri">
275    <xsl:value-of select="m:card/@definitionURL"/>
276   </xsl:variable>
277   <xsl:text>|</xsl:text>
278   <xsl:apply-templates select="*[2]">
279    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
280   </xsl:apply-templates>
281   <xsl:text>|</xsl:text>
282  </xsl:template>
283
284 <!-- COUNTING -->
285
286 <xsl:template match="m:in|m:notin|m:intersect|m:union
287            |m:subset|m:prsubset|m:setdiff|m:card" mode="charcount">
288 <xsl:param name="incurrent_length" select="0"/> 
289     <xsl:choose>
290     <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
291      <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>
292      <xsl:choose>
293      <xsl:when test="string($siblength) = &quot;&quot;">
294       <xsl:value-of select="$incurrent_length + string-length()"/>
295      </xsl:when>
296      <xsl:otherwise>
297       <xsl:value-of select="number($siblength)"/>
298      </xsl:otherwise>
299      </xsl:choose>
300     </xsl:when>
301     <xsl:otherwise>
302      <xsl:value-of select="$incurrent_length + string-length()"/>
303     </xsl:otherwise>
304     </xsl:choose>
305 </xsl:template> 
306
307 </xsl:stylesheet> 
308
309
310
311
312
313
314