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 <!--******************************************************************-->
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">
15 <xsl:include href="params.xsl"/>
21 omit-xml-declaration="no"
23 doctype-public="http://www.w3.org/TR/REC-MathML"
25 media-type="text/mathml" /> -->
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.
38 <!--******************************************************************-->
39 <!-- Variable containing the absolute path of the CIC file -->
40 <!--******************************************************************-->
42 <xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
46 <xsl:template match="LAMBDA" mode="pure">
47 <m:lambda helm:xref="{@id}">
52 <xsl:value-of select="target/@binder"/>
57 <xsl:apply-templates select="source/*[1]" mode="noannot"/>
60 <xsl:apply-templates select="target/*[1]" mode="noannot"/>
64 <xsl:template match="PROD" mode="pure">
65 <m:apply helm:xref="{@id}">
67 <xsl:when test="string(target/@binder)= """>
68 <m:csymbol>arrow</m:csymbol>
69 <xsl:apply-templates select="source/*[1]" mode="noannot"/>
72 <m:csymbol>prod</m:csymbol>
75 <xsl:value-of select="target/@binder"/>
78 <xsl:apply-templates select="source/*[1]" mode="noannot"/>
83 <xsl:apply-templates select="target/*[1]" mode="noannot"/>
87 <xsl:template match="CAST" mode="pure">
88 <m:apply helm:xref="{@id}">
89 <m:csymbol>cast</m:csymbol>
90 <xsl:apply-templates mode="noannot" select="*/*"/>
94 <xsl:template match="REL" mode="pure">
95 <m:ci helm:xref="{@id}">
96 <xsl:value-of select="@binder"/>
100 <xsl:template match="SORT" mode="pure">
101 <m:apply helm:xref="{@id}">
103 <xsl:value-of select="@value"/>
108 <xsl:template match="APPLY" mode="pure">
110 <!-- <xsl:when test="//ALLTYPES and boolean(key('typeid',*/@id))"> -->
111 <!-- start looking for subproofs -->
112 <xsl:when test="((*/@id) = (//ALLTYPES/TYPE/@id))">
113 <m:apply helm:xref="{@id}">
114 <m:csymbol>letin</m:csymbol>
115 <!-- <xsl:for-each select="*[boolean(key('typeid',@id))]"> -->
116 <!-- first process all subproofs (let-in) -->
117 <xsl:for-each select="*[@id = (//ALLTYPES/TYPE/@id)]">
119 <m:csymbol>let</m:csymbol>
120 <m:ci><xsl:value-of select="concat('h',position())"/></m:ci>
121 <xsl:apply-templates mode="noannot" select="."/>
124 <!-- now re-process the application in mode appflat -->
125 <xsl:apply-templates mode="appflat" select="."/>
129 <xsl:apply-templates mode="appflat" select="."/>
134 <xsl:template match="APPLY" mode="appflat">
135 <m:apply helm:xref="{@id}">
136 <m:csymbol>app</m:csymbol>
137 <!-- mode flat looks for siblings: call with the first child -->
138 <xsl:apply-templates mode="flat" select="*[1]"/>
142 <xsl:template match="*" mode="flat">
143 <xsl:param name="n" select="1"/>
145 <xsl:when test="@id">
146 <xsl:variable name="id" select="@id"/>
148 <!-- <xsl:when test="key('typeid',@id)"> -->
149 <xsl:when test="//ALLTYPES/TYPE[@id=$id]">
151 <xsl:value-of select="concat('h',$n)"/>
153 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
154 <xsl:with-param name="n" select="$n+1"/>
155 </xsl:apply-templates>
158 <xsl:apply-templates mode="pure" select="."/>
159 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
160 <xsl:with-param name="n" select="$n"/>
161 </xsl:apply-templates>
166 <xsl:apply-templates mode="pure" select="."/>
167 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
168 <xsl:with-param name="n" select="$n"/>
169 </xsl:apply-templates>
174 <xsl:template match="VAR" mode="pure">
175 <m:ci helm:xref="{@id}">
176 <xsl:value-of select="substring-after(@relUri,",")"/>
180 <xsl:template match="META" mode="pure">
181 <m:ci helm:xref="{@id}">
182 <xsl:value-of select="@no"/>
186 <xsl:template match="CONST" mode="pure">
187 <m:ci definitionURL="{@uri}" helm:xref="{@id}">
188 <xsl:call-template name="name_of_uri">
189 <xsl:with-param name="uri" select="@uri"/>
191 <!-- <xsl:value-of select="document(concat(string($absPath),@uri))/*/@name"/> -->
195 <xsl:template match="MUTIND" mode="pure">
196 <m:ci definitionURL="{@uri}" helm:xref="{@id}">
197 <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
198 <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/>
202 <xsl:template match="MUTCONSTRUCT" mode="pure">
203 <m:ci definitionURL="{@uri}" helm:xref="{@id}">
204 <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
205 <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
206 <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/>
210 <xsl:template match="MUTCASE" mode="pure">
211 <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
212 <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
213 <m:apply helm:xref="{@id}">
214 <m:csymbol>mutcase</m:csymbol>
215 <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
216 <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
217 <xsl:variable name="nop"><xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/@noParams"/></xsl:variable>
218 <xsl:for-each select="pattern">
219 <xsl:variable name="pos" select="position()"/>
220 <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>
222 <xsl:when test="$nopar = 0">
224 <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
229 <m:csymbol>app</m:csymbol>
231 <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
233 <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>
237 <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>
242 <xsl:template match="FIX" mode="pure">
243 <m:apply helm:xref="{@id}">
244 <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
245 <m:csymbol>fix</m:csymbol>
246 <m:ci><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></m:ci>
247 <xsl:apply-templates mode="pure" select="*"/>
251 <xsl:template match="COFIX" mode="pure">
252 <m:apply helm:xref="{@id}">
253 <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
254 <m:csymbol>cofix</m:csymbol>
255 <m:ci><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></m:ci>
256 <xsl:apply-templates mode="pure" select="*"/>
260 <!-- ELEMENTS OF CIC TERMS -->
262 <xsl:template match="FixFunction" mode="pure">
264 <m:ci><xsl:value-of select="@name"/></m:ci>
265 <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
267 <xsl:apply-templates select="body/*[1]" mode="noannot"/>
270 <xsl:template match="CofixFunction" mode="pure">
272 <m:ci><xsl:value-of select="@name"/></m:ci>
273 <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
275 <xsl:apply-templates select="body/*[1]" mode="noannot"/>