]> matita.cs.unibo.it Git - helm.git/blob - helm/style/content.xsl
Initial revision
[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="{@id}">
67      <m:bvar>
68       <m:ci>
69        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
70       </m:ci>
71       <m:type>
72        <xsl:apply-templates select="source/*[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="LETIN" mode="pure">
80     <m:apply helm:xref="{@id}">
81      <m:csymbol>let_in</m:csymbol>
82      <m:bvar>
83       <m:ci>
84        <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="letintarget/@binder"/></xsl:with-param></xsl:call-template>
85       </m:ci>
86      </m:bvar>
87      <xsl:apply-templates select="*[1]" mode="noannot"/>
88      <xsl:apply-templates select="letintarget/*[1]" mode="noannot"/>
89     </m:apply>
90 </xsl:template>
91
92 <xsl:template match="PROD" mode="pure">
93     <m:apply helm:xref="{@id}">
94      <xsl:choose>
95      <xsl:when test="string(target/@binder)= &quot;&quot;">
96       <m:csymbol>arrow</m:csymbol>
97       <xsl:apply-templates select="source/*[1]" mode="noannot"/>
98      </xsl:when>
99      <xsl:otherwise>
100       <xsl:choose>
101        <xsl:when test="@type = 'Prop'">
102         <m:csymbol>forall</m:csymbol>
103        </xsl:when>
104        <xsl:otherwise>
105         <m:csymbol>prod</m:csymbol>
106        </xsl:otherwise>
107       </xsl:choose>
108        <m:bvar>
109         <m:ci>
110          <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
111         </m:ci>
112         <m:type>
113          <xsl:apply-templates select="source/*[1]" mode="noannot"/>
114         </m:type>
115        </m:bvar>
116      </xsl:otherwise>
117      </xsl:choose>
118      <xsl:apply-templates select="target/*[1]" mode="noannot"/>
119     </m:apply>
120 </xsl:template>
121
122 <xsl:template match="CAST" mode="pure">
123     <m:apply helm:xref="{@id}">
124      <m:csymbol>cast</m:csymbol>
125      <xsl:apply-templates mode="noannot" select="*/*"/>
126     </m:apply>
127 </xsl:template>
128
129 <xsl:template match="REL" mode="pure">
130     <m:ci helm:xref="{@id}">
131      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="@binder"/></xsl:with-param></xsl:call-template>
132     </m:ci>
133 </xsl:template>
134
135 <xsl:template match="SORT" mode="pure">
136     <m:apply helm:xref="{@id}">
137      <m:csymbol>
138       <xsl:value-of select="@value"/>
139      </m:csymbol>
140     </m:apply>
141 </xsl:template>
142
143 <xsl:template match="APPLY" mode="pure">
144       <m:apply helm:xref="{@id}">
145        <m:csymbol>app</m:csymbol>
146        <xsl:apply-templates mode="noannot" select="*"/>
147       </m:apply>
148 </xsl:template>
149
150 <!-- Gestione senza pre-processing -->
151 <!-- 
152 <xsl:template match="APPLY" mode="pure">
153      <xsl:apply-templates mode="coercion" select="."/>
154 </xsl:template>
155
156 <xsl:template match="APPLY" mode="no_coercion">
157       <m:apply helm:xref="{@id}">
158        <m:csymbol>app</m:csymbol>
159        <xsl:apply-templates mode="noannot" select="*"/>
160       </m:apply>
161 </xsl:template>
162 -->
163
164 <xsl:template match="VAR" mode="pure">
165     <m:ci helm:xref="{@id}">
166      <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="substring-after(@relUri,&quot;,&quot;)"/></xsl:with-param></xsl:call-template>
167     </m:ci>
168 </xsl:template>
169
170 <xsl:template match="META" mode="pure">
171    <m:apply helm:xref="{@id}">
172     <m:csymbol>meta</m:csymbol>
173     <m:ci>
174      <xsl:call-template name="insert_subscript">
175       <xsl:with-param name="node_value">
176        <xsl:text>?</xsl:text>
177        <xsl:value-of select="@no"/>
178       </xsl:with-param>
179      </xsl:call-template>
180     </m:ci>
181     <xsl:for-each select="substitution">
182      <xsl:choose>
183       <xsl:when test="*[1]">
184        <xsl:apply-templates select="*[1]" mode="noannot"/>
185       </xsl:when>
186       <xsl:otherwise>
187        <m:ci>_</m:ci>
188       </xsl:otherwise>
189      </xsl:choose>
190     </xsl:for-each>
191    </m:apply>
192 </xsl:template>
193
194 <xsl:template match="CONST" mode="pure">
195    <m:ci definitionURL="{@uri}" helm:xref="{@id}">
196       <xsl:call-template name="insert_subscript">
197          <xsl:with-param name="node_value">
198             <xsl:call-template name="name_of_uri">
199                <xsl:with-param name="uri" select="@uri"/>
200             </xsl:call-template>
201          </xsl:with-param>
202       </xsl:call-template>
203    </m:ci>
204 </xsl:template>
205
206 <xsl:template match="MUTIND" mode="pure">
207     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
208      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
209      <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
210      <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>
211     </m:ci>
212 </xsl:template>
213
214 <xsl:template match="MUTCONSTRUCT" mode="pure">
215     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
216      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="@uri"/></xsl:call-template></xsl:variable>
217      <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
218      <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
219      <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>
220     </m:ci>
221 </xsl:template>
222
223 <xsl:template match="MUTCASE" mode="pure">
224     <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
225     <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
226      <xsl:variable name="InductiveTypeUrl"><xsl:call-template name="URLofURI4getter"><xsl:with-param name="uri" select="$Turi"/></xsl:call-template></xsl:variable>
227     <xsl:variable name="InductiveTypeDoc" select="document($InductiveTypeUrl)"/>
228     <m:apply helm:xref="{@id}">
229      <m:csymbol>mutcase</m:csymbol>
230      <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
231      <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
232      <xsl:variable name="nop"><xsl:value-of select="$InductiveTypeDoc/InductiveDefinition/@noParams"/></xsl:variable>
233      <m:piecewise>
234       <xsl:for-each select="pattern">
235        <xsl:variable name="pos" select="position()"/>
236        <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>
237        <m:piece>
238         <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>
239         <xsl:choose>
240         <xsl:when test="$nopar = 0">
241          <m:ci>
242           <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>
243          </m:ci>
244         </xsl:when>
245         <xsl:otherwise>
246          <m:apply>
247           <m:csymbol>app</m:csymbol>
248           <m:ci>
249            <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>
250           </m:ci>
251           <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>
252           </m:apply>
253          </xsl:otherwise>
254          </xsl:choose>
255         </m:piece>
256       </xsl:for-each>
257      </m:piecewise> 
258     </m:apply>
259 </xsl:template>
260
261 <xsl:template match="FIX" mode="pure">
262     <m:apply helm:xref="{@id}">
263      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
264      <m:csymbol>fix</m:csymbol>
265      <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>
266      <xsl:apply-templates mode="pure" select="*"/>
267     </m:apply>
268 </xsl:template>
269
270 <xsl:template match="COFIX" mode="pure">
271    <m:apply helm:xref="{@id}">
272      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
273      <m:csymbol>cofix</m:csymbol>
274      <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>
275      <xsl:apply-templates mode="pure" select="*"/>
276     </m:apply>
277 </xsl:template>
278
279 <!-- ELEMENTS OF CIC TERMS -->
280
281 <xsl:template match="FixFunction" mode="pure">
282     <m:bvar>
283      <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>
284      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
285     </m:bvar> 
286     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
287 </xsl:template>
288
289 <xsl:template match="CofixFunction" mode="pure">
290     <m:bvar>
291      <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>
292      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
293     </m:bvar> 
294     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
295 </xsl:template>
296
297 </xsl:stylesheet>