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