]> matita.cs.unibo.it Git - helm.git/blob - helm/style/html_set.xsl
added notations for abstact polinomials
[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" select="@definitionURL"/>
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" SIZE="+2" 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 href="{$uri}">
125    <FONT FACE="symbol" SIZE="+2" mathcolor="blue">
126     <xsl:value-of select="$symbol"/>
127    </FONT>
128   </a>
129   <xsl:apply-templates mode="inline" select="*[3]"/>
130   <xsl:text>)</xsl:text>
131  </xsl:template>
132
133 <!-- *************************************************************** -->
134
135 <xsl:template match="m:apply[m:in|m:notin|m:intersect|m:union
136   |m:subset|m:prsubset|m:setdiff]">
137   <xsl:param name="current_indent" select="0"/> 
138   <xsl:param name="width" select="$framewidth"/>
139   <xsl:variable name="uri">
140    <xsl:value-of select="*[1]/@definitionURL"/>
141   </xsl:variable>
142   <xsl:variable name="charlength">
143    <xsl:apply-templates select="*[1]" mode="charcount"/>
144   </xsl:variable>
145   <xsl:variable name="symbol">
146    <xsl:choose>
147     <xsl:when test="m:in">
148      <xsl:value-of select="'&#206;'"/>
149     </xsl:when>
150     <xsl:when test="m:notin">
151      <xsl:value-of select="'&#207;'"/>
152     </xsl:when>
153     <xsl:when test="m:intersect">
154      <xsl:value-of select="'&#199;'"/>
155     </xsl:when>
156     <xsl:when test="m:union">
157      <xsl:value-of select="'&#200;'"/>
158     </xsl:when>
159     <xsl:when test="m:subset">
160      <xsl:value-of select="'&#205;'"/>
161     </xsl:when>
162     <xsl:when test="m:prsubset">
163      <xsl:value-of select="'&#204;'"/>
164     </xsl:when>
165     <xsl:when test="m:setdiff">
166      <xsl:value-of select="'/'"/>
167     </xsl:when>
168    </xsl:choose>
169   </xsl:variable>
170   <xsl:choose>
171     <xsl:when test="$charlength > $framewidth">
172      <xsl:text>(</xsl:text>
173      <xsl:apply-templates select="*[2]">
174       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
175      </xsl:apply-templates>
176      <BR/> 
177      <xsl:call-template name="make_indent">
178       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
179      </xsl:call-template>
180      <a href="{$uri}">
181       <FONT FACE="symbol" SIZE="+2" mathcolor="blue">
182        <xsl:value-of select="$symbol"/>
183       </FONT>
184      </a>
185      <xsl:apply-templates select="*[3]">
186       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
187      </xsl:apply-templates>
188      <xsl:text>)</xsl:text>
189     </xsl:when>
190     <xsl:otherwise>
191      <xsl:apply-templates mode="inline" select="."/>
192     </xsl:otherwise>
193    </xsl:choose>
194  </xsl:template>
195
196
197 <!-- SET -->
198
199  <xsl:template match="m:set">
200   <xsl:param name="current_indent" select="0"/> 
201   <xsl:param name="width" select="$framewidth"/>
202   <xsl:variable name="uri" select="@definitionURL"/>
203 <!--   <xsl:value-of select="concat(string($absPath), @definitionURL)"/>
204   </xsl:variable>-->
205   <xsl:choose>
206    <xsl:when test="count(child::*) = 0">
207     <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#198;</FONT>
208    </xsl:when>
209    <xsl:otherwise>
210     <xsl:variable name="charlength">
211      <xsl:apply-templates select="." mode="charcount"/>
212     </xsl:variable>
213     <xsl:choose>
214      <xsl:when test="$charlength > $framewidth">
215       <xsl:choose>
216        <xsl:when test="name(*[1]) = 'm:bvar'">
217         <xsl:text>{</xsl:text>
218         <xsl:apply-templates select="m:bvar/m:ci"/>
219         <xsl:text>:</xsl:text>
220         <xsl:apply-templates select="m:bvar/m:type">
221          <xsl:with-param name="current_indent" 
222            select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
223         </xsl:apply-templates><BR/>
224         <xsl:call-template name="make_indent">
225          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
226         </xsl:call-template>
227         <xsl:text>|</xsl:text>
228         <xsl:apply-templates select="m:condition">
229          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
230         </xsl:apply-templates>
231         <xsl:text>}</xsl:text>
232        </xsl:when>
233        <xsl:otherwise>
234         <xsl:text>{</xsl:text>
235          <xsl:apply-templates select="*[position()=1]">
236           <xsl:with-param name="current_indent" select="$current_indent + 2"/>
237          </xsl:apply-templates>
238          <xsl:for-each select="*[position()>1]">
239           <xsl:text>,</xsl:text>
240           <BR/>
241           <xsl:call-template name="make_indent">
242            <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
243           </xsl:call-template>
244           <xsl:apply-templates select=".">
245            <xsl:with-param name="current_indent" select="$current_indent + 2"/>
246           </xsl:apply-templates>
247          </xsl:for-each>
248         <xsl:text>}</xsl:text>
249        </xsl:otherwise>
250       </xsl:choose>
251      </xsl:when>
252      <xsl:otherwise>
253       <xsl:apply-templates mode="inline" select="."/>
254      </xsl:otherwise>
255     </xsl:choose>
256    </xsl:otherwise>
257   </xsl:choose>
258  </xsl:template> 
259
260 <!-- CARD -->
261 <xsl:template match="m:apply[m:card]">
262   <xsl:param name="current_indent" select="0"/> 
263   <xsl:param name="width" select="$framewidth"/>
264   <xsl:variable name="uri">
265    <xsl:value-of select="m:card/@definitionURL"/>
266   </xsl:variable>
267   <xsl:text>|</xsl:text>
268   <xsl:apply-templates select="*[2]">
269    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
270   </xsl:apply-templates>
271   <xsl:text>|</xsl:text>
272  </xsl:template>
273
274 <!-- COUNTING -->
275
276 <xsl:template match="m:in|m:notin|m:intersect|m:union
277            |m:subset|m:prsubset|m:setdiff|m:card" mode="charcount">
278 <xsl:param name="incurrent_length" select="0"/> 
279     <xsl:choose>
280     <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
281      <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>
282      <xsl:choose>
283      <xsl:when test="string($siblength) = &quot;&quot;">
284       <xsl:value-of select="$incurrent_length + string-length()"/>
285      </xsl:when>
286      <xsl:otherwise>
287       <xsl:value-of select="number($siblength)"/>
288      </xsl:otherwise>
289      </xsl:choose>
290     </xsl:when>
291     <xsl:otherwise>
292      <xsl:value-of select="$incurrent_length + string-length()"/>
293     </xsl:otherwise>
294     </xsl:choose>
295 </xsl:template> 
296
297 </xsl:stylesheet> 
298
299
300
301
302
303
304