]> matita.cs.unibo.it Git - helm.git/blob - helm/style/content_senza_tipi.13.9.00.xsl
Initial revision
[helm.git] / helm / style / content_senza_tipi.13.9.00.xsl
1 <?xml version="1.0"?>
2
3 <!--******************************************************************--> 
4 <!-- XSLT version 0.1 of CIC objects to MathML content:               -->
5 <!-- First draft: February 14 2000, Andrea Asperti, Irene Schena      -->
6 <!-- Revised: March 3 2000, Irene Schena                              -->
7 <!-- Revised: March 10 2000, Irene Schena                             -->
8 <!-- Revised: March 15 2000, Claudio Sacerdoti Coen, Irene Schena     -->
9 <!--******************************************************************-->
10
11 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12                               xmlns:m="http://www.w3.org/1998/Math/MathML"
13                               xmlns:helm="http://www.cs.unibo.it/helm">
14
15 <xsl:include href="params.xsl"/>
16
17 <!--<xsl:output
18            method="xml" 
19            version="1.0" 
20            encoding="ISO-8859-1" 
21            omit-xml-declaration="no"
22            standalone="no" 
23            doctype-public="http://www.w3.org/TR/REC-MathML" 
24            indent="yes"
25            media-type="text/mathml" /> -->
26
27 <!-- DA FARE: 
28 1)risolvere nella fase di pre-processing le uri relative, settando l'attributo
29 definitionURL dell'oggetto corrispondente (alcuni punteranno a nulla! -quelli 
30 che non hanno il file di definizione corrispondente-); [le uri assolute hanno
31 la forma cic:/.../ in definitionURL e questo schema di uri verra' risolto da
32 Amaya o da chi di dovere in /really_very_local/helm/PARSER/example/.../]
33 2)aggiungere nei file xml gli ID, affinche' nello stylesheet si setti
34 l'attributo xref di ogni oggetto per puntare (tramite ID) al suo corrispondente
35 della rappresentazione interna. 
36 -->
37
38 <!--******************************************************************-->
39 <!-- Variable containing the absolute path of the CIC file            -->
40 <!--******************************************************************-->
41
42 <xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
43
44 <!-- CIC TERMS -->
45
46 <xsl:template match="LAMBDA" mode="noannot">
47     <m:lambda helm:xref="{@id}">
48      <m:bvar>
49       <m:ci>
50        <xsl:value-of select="target/@binder"/>
51       </m:ci>
52       <m:type>
53        <xsl:apply-templates select="source/*[1]" mode="noannot"/>
54       </m:type>
55      </m:bvar>
56      <xsl:apply-templates select="target/*[1]" mode="noannot"/>
57     </m:lambda>
58 </xsl:template>
59
60 <xsl:template match="PROD" mode="noannot">
61     <m:apply helm:xref="{@id}">
62      <xsl:choose>
63      <xsl:when test="string(target/@binder)= &quot;&quot;">
64       <m:csymbol>arrow</m:csymbol>
65       <xsl:apply-templates select="source/*[1]" mode="noannot"/>
66      </xsl:when>
67      <xsl:otherwise>
68       <m:csymbol>prod</m:csymbol>
69        <m:bvar>
70         <m:ci>
71          <xsl:value-of select="target/@binder"/>
72         </m:ci>
73         <m:type>
74          <xsl:apply-templates select="source/*[1]" mode="noannot"/>
75         </m:type>
76        </m:bvar>
77      </xsl:otherwise>
78      </xsl:choose>
79      <xsl:apply-templates select="target/*[1]" mode="noannot"/>
80     </m:apply>
81 </xsl:template>
82
83 <xsl:template match="CAST" mode="noannot">
84     <m:apply helm:xref="{@id}">
85      <m:csymbol>cast</m:csymbol>
86      <xsl:apply-templates mode="noannot" select="*/*"/>
87     </m:apply>
88 </xsl:template>
89
90 <xsl:template match="REL" mode="noannot">
91     <m:ci helm:xref="{@id}">
92      <xsl:value-of select="@binder"/>
93     </m:ci>
94 </xsl:template>
95
96 <xsl:template match="SORT" mode="noannot">
97     <m:apply helm:xref="{@id}">
98      <m:csymbol>
99       <xsl:value-of select="@value"/>
100      </m:csymbol>
101     </m:apply>
102 </xsl:template>
103
104 <xsl:template match="APPLY" mode="noannot">
105     <m:apply helm:xref="{@id}">
106     <m:csymbol>app</m:csymbol>
107      <xsl:apply-templates mode="noannot" select="*"/>
108     </m:apply>
109 </xsl:template>
110
111 <xsl:template match="VAR" mode="noannot">
112     <m:ci helm:xref="{@id}">
113      <xsl:value-of select="substring-after(@relUri,&quot;,&quot;)"/>
114     </m:ci>
115 </xsl:template>
116
117 <xsl:template match="META" mode="noannot">
118     <m:ci helm:xref="{@id}">
119      <xsl:value-of select="@no"/>
120     </m:ci>
121 </xsl:template>
122
123 <xsl:template match="CONST" mode="noannot">
124     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
125      <xsl:call-template name="name_of_uri">
126       <xsl:with-param name="uri" select="@uri"/>
127      </xsl:call-template>
128      <!-- <xsl:value-of select="document(concat(string($absPath),@uri))/*/@name"/> -->
129     </m:ci>
130 </xsl:template>
131
132 <xsl:template match="MUTIND" mode="noannot">
133     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
134      <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
135      <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/>
136     </m:ci>
137 </xsl:template>
138
139 <xsl:template match="MUTCONSTRUCT" mode="noannot">
140     <m:ci definitionURL="{@uri}" helm:xref="{@id}">
141      <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
142      <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
143      <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/>
144     </m:ci>
145 </xsl:template>
146
147 <xsl:template match="MUTCASE" mode="noannot">
148     <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
149     <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
150     <m:apply helm:xref="{@id}">
151      <m:csymbol>mutcase</m:csymbol>
152      <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
153      <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
154      <xsl:variable name="nop"><xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/@noParams"/></xsl:variable>
155      <xsl:for-each select="pattern">
156       <xsl:variable name="pos" select="position()"/>
157       <xsl:variable name="nopar"><xsl:apply-templates select="document(concat(string($absPath),$Turi))/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>
158       <xsl:choose>
159       <xsl:when test="$nopar = 0">
160        <m:ci>
161         <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
162        </m:ci>
163       </xsl:when>
164       <xsl:otherwise>
165        <m:apply>
166         <m:csymbol>app</m:csymbol>
167         <m:ci>
168          <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
169         </m:ci>
170         <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>
171         </m:apply>
172        </xsl:otherwise>
173        </xsl:choose>
174       <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>
175      </xsl:for-each> 
176     </m:apply>
177 </xsl:template>
178
179 <xsl:template match="FIX" mode="noannot">
180     <m:apply helm:xref="{@id}">
181      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
182      <m:csymbol>fix</m:csymbol>
183      <m:ci><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></m:ci>
184      <xsl:apply-templates mode="noannot" select="*"/>
185     </m:apply>
186 </xsl:template>
187
188 <xsl:template match="COFIX" mode="noannot">
189    <m:apply helm:xref="{@id}">
190      <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
191      <m:csymbol>cofix</m:csymbol>
192      <m:ci><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></m:ci>
193      <xsl:apply-templates mode="noannot" select="*"/>
194     </m:apply>
195 </xsl:template>
196
197 <!-- ELEMENTS OF CIC TERMS -->
198
199 <xsl:template match="FixFunction" mode="noannot">
200     <m:bvar>
201      <m:ci><xsl:value-of select="@name"/></m:ci>
202      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
203     </m:bvar> 
204     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
205 </xsl:template>
206
207 <xsl:template match="CofixFunction" mode="noannot">
208     <m:bvar>
209      <m:ci><xsl:value-of select="@name"/></m:ci>
210      <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
211     </m:bvar> 
212     <xsl:apply-templates select="body/*[1]" mode="noannot"/>
213 </xsl:template>
214
215 </xsl:stylesheet>