]> matita.cs.unibo.it Git - helm.git/blob - helm/style/content.xsl
- removed checkings for objects Definition and Axiom.
[helm.git] / helm / style / content.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 <!--******************************************************************--> 
28 <!-- XSLT version 0.1 of CIC objects to MathML content:               -->
29 <!-- First draft: February 14 2000, Andrea Asperti, Irene Schena      -->
30 <!-- Revised: March 3 2000, Irene Schena                              -->
31 <!-- Revised: March 10 2000, Irene Schena                             -->
32 <!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena     -->
33 <!--******************************************************************-->
34
35 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
36                               xmlns:m="http://www.w3.org/1998/Math/MathML"
37                               xmlns:helm="http://www.cs.unibo.it/helm">
38
39 <xsl:include href="params.xsl"/>
40 <!-- adesso sono preprocessate -->
41 <!-- <xsl:include href="coercions.xsl"/> -->
42
43 <!--<xsl:output
44            method="xml" 
45            version="1.0" 
46            encoding="ISO-8859-1" 
47            omit-xml-declaration="no"
48            standalone="no" 
49            doctype-public="http://www.w3.org/TR/REC-MathML" 
50            indent="yes"
51            media-type="text/mathml" /> -->
52
53 <!-- DA FARE: 
54 1)risolvere nella fase di pre-processing le uri relative delle var, settando 
55 l'attributo
56 definitionURL dell'oggetto corrispondente (alcuni punteranno a nulla! -quelli 
57 che non hanno il file di definizione corrispondente-); [le uri assolute hanno
58 la forma cic:/.../ in definitionURL e questo schema di uri verra' risolto da
59 Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
60 -->
61
62
63 <!-- CIC TERMS -->
64
65 <!--xsl:template match="LAMBDA" mode="pure">
66     <m:lambda helm:xref="{decl/@id}">
67      <m:bvar>
68       <m:ci>
69        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="decl/@binder"/></xsl:with-param></xsl:call-template>
70       </m:ci>
71       <m:type>
72        <xsl:apply-templates select="decl/*[1]" mode="noannot"/>
73       </m:type>
74      </m:bvar>
75      <xsl:apply-templates select="target/*[1]" mode="noannot"/>
76     </m:lambda>
77 </xsl:template-->
78
79 <!--xsl:template match="LAMBDA" mode="pure">
80         <xsl:for-each select="decl">
81          <m:lambda helm:xref="{@id}">
82           <m:bvar>
83            <m:ci>
84             <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
85            </m:ci>
86            <m:type>
87             <xsl:apply-templates select="*[1]" mode="noannot"/>
88            </m:type>
89           </m:bvar>
90          </m:lambda>
91         </xsl:for-each>
92         <xsl:apply-templates select="target/*[1]" mode="noannot"/-->
93          <!--xsl:for-each select="decl">
94           </m:lambda>
95          </xsl:for-each-->
96 <!--/xsl:template-->
97
98 <xsl:template match="LAMBDA" mode="pure">
99         <xsl:apply-templates select="*[1]" mode="lambda"/>
100 </xsl:template>
101
102 <xsl:template match="decl" mode="lambda">
103         <m:lambda helm:xref="{@id}">
104          <m:bvar>
105           <m:ci>
106            <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
107           </m:ci>
108           <m:type>
109            <xsl:apply-templates select="*[1]" mode="noannot"/>
110           </m:type>
111          </m:bvar>
112         <xsl:apply-templates select="following-sibling::*[1]" mode="lambda"/>
113         </m:lambda>
114 </xsl:template>
115
116 <xsl:template match="target" mode="lambda">
117         <xsl:apply-templates select="*[1]" mode="noannot"/>
118 </xsl:template>
119
120 <!--xsl:template match="LETIN" mode="pure">
121     <m:apply helm:xref="{@id}">
122      <m:csymbol>let_in</m:csymbol>
123      <m:bvar>
124       <m:ci>
125        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="letintarget/@binder"/></xsl:with-param></xsl:call-template>
126       </m:ci>
127      </m:bvar>
128      <xsl:apply-templates select="*[1]" mode="noannot"/>
129      <xsl:apply-templates select="letintarget/*[1]" mode="noannot"/>
130     </m:apply>
131 </xsl:template-->
132
133 <xsl:template match="LETIN" mode="pure">
134         <xsl:apply-templates select="*[1]" mode="letin"/>
135 </xsl:template>
136
137 <xsl:template match="def" mode="letin"> 
138     <m:apply helm:xref="{@id}">
139      <m:csymbol>let_in</m:csymbol>
140      <m:bvar>
141       <m:ci>
142        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
143       </m:ci>
144      </m:bvar>
145      <xsl:apply-templates select="*[1]" mode="noannot"/>
146      <xsl:apply-templates select="following-sibling::*[1]" mode="letin"/>
147     </m:apply>
148 </xsl:template>
149
150 <xsl:template match="target" mode="letin">
151         <xsl:apply-templates select="*[1]" mode="noannot"/>
152 </xsl:template>
153
154 <!--xsl:template match="PROD" mode="pure">
155     <xsl:for-each select="decl">
156      <m:apply helm:xref="{@id}">
157       <xsl:choose>
158        <xsl:when test="string(@binder)= &quot;&quot;">
159         <m:csymbol>arrow</m:csymbol>
160         <xsl:apply-templates select="*[1]" mode="noannot"/>
161        </xsl:when>
162        <xsl:otherwise>
163         <xsl:choose>
164          <xsl:when test="../@type = 'Prop'">
165           <m:csymbol>forall</m:csymbol>
166          </xsl:when>
167          <xsl:otherwise>
168           <m:csymbol>prod</m:csymbol>
169          </xsl:otherwise>
170         </xsl:choose>
171         <m:bvar>
172          <m:ci>
173           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
174          </m:ci>
175          <m:type>
176           <xsl:apply-templates select="*[1]" mode="noannot"/>
177          </m:type>
178         </m:bvar>
179        </xsl:otherwise>
180       </xsl:choose>
181      </m:apply>
182     </xsl:for-each>
183     <xsl:apply-templates select="target/*[1]" mode="noannot"/> 
184 </xsl:template-->
185
186 <xsl:template match="PROD" mode="pure">
187         <xsl:apply-templates select="*[1]" mode="prod"/>
188 </xsl:template>
189
190 <xsl:template match="decl" mode="prod">
191      <m:apply helm:xref="{@id}">
192       <xsl:choose>
193        <xsl:when test="string(@binder)= &quot;&quot;">
194         <m:csymbol>arrow</m:csymbol>
195         <xsl:apply-templates select="*[1]" mode="noannot"/>
196        </xsl:when>
197        <xsl:otherwise>
198         <xsl:choose>
199          <xsl:when test="../@type = 'Prop'">
200           <m:csymbol>forall</m:csymbol>
201          </xsl:when>
202          <xsl:otherwise>
203           <m:csymbol>prod</m:csymbol>
204          </xsl:otherwise>
205         </xsl:choose>
206         <m:bvar>
207          <m:ci>
208           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
209          </m:ci>
210          <m:type>
211           <xsl:apply-templates select="*[1]" mode="noannot"/>
212          </m:type>
213         </m:bvar>
214        </xsl:otherwise>
215       </xsl:choose>
216      <xsl:apply-templates select="following-sibling::*[1]" mode="prod"/> 
217      </m:apply>
218 </xsl:template>
219
220          
221 <xsl:template match="target" mode="prod">
222         <xsl:apply-templates select="*[1]" mode="noannot"/>
223 </xsl:template>
224
225 <xsl:template match="CAST" mode="pure">
226     <m:apply helm:xref="{@id}">
227      <m:csymbol>cast</m:csymbol>
228      <xsl:apply-templates mode="noannot" select="*/*"/>
229     </m:apply>
230 </xsl:template>
231
232 <xsl:template match="REL" mode="pure">
233     <m:ci helm:xref="{@id}">
234      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
235     </m:ci>
236 </xsl:template>
237
238 <xsl:template match="SORT" mode="pure">
239     <m:apply helm:xref="{@id}">
240      <m:csymbol>
241       <xsl:value-of select="@value"/>
242      </m:csymbol>
243     </m:apply>
244 </xsl:template>
245
246 <xsl:template match="APPLY" mode="pure">
247       <m:apply helm:xref="{@id}">
248        <m:csymbol>app</m:csymbol>
249        <xsl:apply-templates mode="noannot" select="*"/>
250       </m:apply>
251 </xsl:template>
252
253 <!-- Gestione senza pre-processing -->
254 <!-- 
255 <xsl:template match="APPLY" mode="pure">
256      <xsl:apply-templates mode="coercion" select="."/>
257 </xsl:template>
258
259 <xsl:template match="APPLY" mode="no_coercion">
260       <m:apply helm:xref="{@id}">
261        <m:csymbol>app</m:csymbol>
262        <xsl:apply-templates mode="noannot" select="*"/>
263       </m:apply>
264 </xsl:template>
265 -->
266
267 <xsl:template match="VAR" mode="pure">
268     <m:ci helm:xref="{@id}">
269      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:call-template name="name_of_uri_bis">
270           <xsl:with-param name="uri" select="@uri"/>
271               </xsl:call-template>
272               </xsl:with-param></xsl:call-template>
273     </m:ci>
274 </xsl:template>
275
276 <xsl:template match="META" mode="pure">
277    <m:apply helm:xref="{@id}">
278     <m:csymbol>meta</m:csymbol>
279     <m:ci>
280      <xsl:call-template name="insert_subscript">
281       <xsl:with-param name="node_value">
282        <xsl:text>?</xsl:text>
283        <xsl:value-of select="@no"/>
284       </xsl:with-param>
285      </xsl:call-template>
286     </m:ci>
287     <xsl:for-each select="substitution">
288      <xsl:choose>
289       <xsl:when test="*[1]">
290        <xsl:apply-templates select="*[1]" mode="noannot"/>
291       </xsl:when>
292       <xsl:otherwise>
293        <m:ci>_</m:ci>
294       </xsl:otherwise>
295      </xsl:choose>
296     </xsl:for-each>
297    </m:apply>
298 </xsl:template>
299
300 <xsl:template match="CONST" mode="pure">
301    <m:ci definitionURL="{@uri}" helm:xref="{@id}">
302       <xsl:call-template name="insert_subscript">
303          <xsl:with-param name="node_value">
304             <xsl:call-template name="name_of_uri">
305                <xsl:with-param name="uri" select="@uri"/>
306             </xsl:call-template>
307          </xsl:with-param>
308       </xsl:call-template>
309    </m:ci>
310 </xsl:template>
311
312 <xsl:template match="MUTIND" mode="pure">
313     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
314      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
315      <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
316      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document($InductiveTypeUrl)/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/></xsl:with-param></xsl:call-template>
317     </m:ci>
318 </xsl:template>
319
320 <xsl:template match="MUTCONSTRUCT" mode="pure">
321     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
322      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
323      <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
324      <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
325      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="document($InductiveTypeUrl)/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/></xsl:with-param></xsl:call-template>
326     </m:ci>
327 </xsl:template>
328
329 <xsl:template match="MUTCASE" mode="pure">
330     <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
331     <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
332      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$Turi"/></xsl:call-template></xsl:variable>
333     <xsl:variable name="InductiveTypeDoc" select="document($InductiveTypeUrl)"/>
334     <m:apply helm:xref="{@id}">
335      <m:csymbol>mutcase</m:csymbol>
336      <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
337      <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
338      <xsl:variable name="nop"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/@noParams"/></xsl:variable>
339      <m:piecewise>
340       <xsl:for-each select="pattern">
341        <xsl:variable name="pos" select="position()"/>
342        <xsl:variable name="nopar"><xsl:apply-templates select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/*[1]" mode="counting"><xsl:with-param name="noparams" select="$nop"/></xsl:apply-templates></xsl:variable>
343        <m:piece>
344         <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="target" select="1"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
345         <xsl:choose>
346         <xsl:when test="$nopar = 0">
347          <m:ci>
348           <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/></xsl:with-param></xsl:call-template>
349          </m:ci>
350         </xsl:when>
351         <xsl:otherwise>
352          <m:apply>
353           <m:csymbol>app</m:csymbol>
354           <m:ci>
355            <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/></xsl:with-param></xsl:call-template>
356           </m:ci>
357           <xsl:apply-templates select="./*[1]" mode="abstparams"><xsl:with-param name="noparams" select="$nopar"/><xsl:with-param name="binder">LAMBDA</xsl:with-param></xsl:apply-templates>
358           </m:apply>
359          </xsl:otherwise>
360          </xsl:choose>
361         </m:piece>
362       </xsl:for-each>
363      </m:piecewise> 
364     </m:apply>
365 </xsl:template>
366
367 <xsl:template match="FIX" mode="pure">
368     <m:apply helm:xref="{@id}">
369      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
370      <m:csymbol>fix</m:csymbol>
371      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></xsl:with-param></xsl:call-template></m:ci>
372      <xsl:apply-templates mode="pure" select="*"/>
373     </m:apply>
374 </xsl:template>
375
376 <xsl:template match="COFIX" mode="pure">
377    <m:apply helm:xref="{@id}">
378      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
379      <m:csymbol>cofix</m:csymbol>
380      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></xsl:with-param></xsl:call-template></m:ci>
381      <xsl:apply-templates mode="pure" select="*"/>
382     </m:apply>
383 </xsl:template>
384
385 <!-- ELEMENTS OF CIC TERMS -->
386
387 <xsl:template match="FixFunction" mode="pure">
388     <m:bvar>
389      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template></m:ci>
390      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
391     </m:bvar> 
392     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
393 </xsl:template>
394
395 <xsl:template match="CofixFunction" mode="pure">
396     <m:bvar>
397      <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@name"/></xsl:with-param></xsl:call-template></m:ci>
398      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
399     </m:bvar> 
400     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
401 </xsl:template>
402
403 </xsl:stylesheet>