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}">
50 <xsl:value-of select="target/@binder"/>
53 <xsl:apply-templates select="source/*[1]" mode="noannot"/>
56 <xsl:apply-templates select="target/*[1]" mode="noannot"/>
60 <xsl:template match="PROD" mode="pure">
61 <m:apply helm:xref="{@id}">
63 <xsl:when test="string(target/@binder)= """>
64 <m:csymbol>arrow</m:csymbol>
65 <xsl:apply-templates select="source/*[1]" mode="noannot"/>
68 <m:csymbol>prod</m:csymbol>
71 <xsl:value-of select="target/@binder"/>
74 <xsl:apply-templates select="source/*[1]" mode="noannot"/>
79 <xsl:apply-templates select="target/*[1]" mode="noannot"/>
83 <xsl:template match="CAST" mode="pure">
84 <m:apply helm:xref="{@id}">
85 <m:csymbol>cast</m:csymbol>
86 <xsl:apply-templates mode="noannot" select="*/*"/>
90 <xsl:template match="REL" mode="pure">
91 <m:ci helm:xref="{@id}">
92 <xsl:value-of select="@binder"/>
96 <xsl:template match="SORT" mode="pure">
97 <m:apply helm:xref="{@id}">
99 <xsl:value-of select="@value"/>
104 <xsl:template match="APPLY" mode="pure">
106 <!-- <xsl:when test="//ALLTYPES and boolean(key('typeid',*/@id))"> -->
107 <!-- start looking for subproofs -->
108 <xsl:when test="((*/@id) = (//ALLTYPES/TYPE/@id))">
109 <m:apply helm:xref="{@id}">
110 <m:csymbol>letin</m:csymbol>
111 <!-- <xsl:for-each select="*[boolean(key('typeid',@id))]"> -->
112 <!-- first process all subproofs (let-in) -->
113 <xsl:for-each select="*[@id = (//ALLTYPES/TYPE/@id)]">
115 <m:csymbol>let</m:csymbol>
116 <m:ci><xsl:value-of select="concat('h',position())"/></m:ci>
117 <xsl:apply-templates mode="noannot" select="."/>
120 <!-- now re-process the application in mode appflat -->
121 <xsl:apply-templates mode="appflat" select="."/>
125 <xsl:apply-templates mode="appflat" select="."/>
130 <xsl:template match="APPLY" mode="appflat">
131 <m:apply helm:xref="{@id}">
132 <m:csymbol>app</m:csymbol>
133 <!-- mode flat looks for siblings: call with the first child -->
134 <xsl:apply-templates mode="flat" select="*[1]"/>
138 <xsl:template match="*" mode="flat">
139 <xsl:param name="n" select="1"/>
141 <xsl:when test="@id">
142 <xsl:variable name="id" select="@id"/>
144 <!-- <xsl:when test="key('typeid',@id)"> -->
145 <xsl:when test="//ALLTYPES/TYPE[@id=$id]">
147 <xsl:value-of select="concat('h',$n)"/>
149 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
150 <xsl:with-param name="n" select="$n+1"/>
151 </xsl:apply-templates>
154 <xsl:apply-templates mode="pure" select="."/>
155 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
156 <xsl:with-param name="n" select="$n"/>
157 </xsl:apply-templates>
162 <xsl:apply-templates mode="pure" select="."/>
163 <xsl:apply-templates mode="flat" select="following-sibling::*[1]">
164 <xsl:with-param name="n" select="$n"/>
165 </xsl:apply-templates>
170 <xsl:template match="VAR" mode="pure">
171 <m:ci helm:xref="{@id}">
172 <xsl:value-of select="substring-after(@relUri,",")"/>
176 <xsl:template match="META" mode="pure">
177 <m:ci helm:xref="{@id}">
178 <xsl:value-of select="@no"/>
182 <xsl:template match="CONST" mode="pure">
183 <m:ci definitionURL="{@uri}" helm:xref="{@id}">
184 <xsl:call-template name="name_of_uri">
185 <xsl:with-param name="uri" select="@uri"/>
187 <!-- <xsl:value-of select="document(concat(string($absPath),@uri))/*/@name"/> -->
191 <xsl:template match="MUTIND" mode="pure">
192 <m:ci definitionURL="{@uri}" helm:xref="{@id}">
193 <xsl:variable name="index"><xsl:value-of select="@noType"/></xsl:variable>
194 <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($index)+1]/@name"/>
198 <xsl:template match="MUTCONSTRUCT" mode="pure">
199 <m:ci definitionURL="{@uri}" helm:xref="{@id}">
200 <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
201 <xsl:variable name="Cindex"><xsl:value-of select="@noConstr"/></xsl:variable>
202 <xsl:value-of select="document(concat(string($absPath),@uri))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($Cindex)]/@name"/>
206 <xsl:template match="MUTCASE" mode="pure">
207 <xsl:variable name="Tindex"><xsl:value-of select="@noType"/></xsl:variable>
208 <xsl:variable name="Turi"><xsl:value-of select="@uriType"/></xsl:variable>
209 <m:apply helm:xref="{@id}">
210 <m:csymbol>mutcase</m:csymbol>
211 <xsl:apply-templates select="patternsType/*[1]" mode="noannot"/>
212 <xsl:apply-templates select="inductiveTerm/*[1]" mode="noannot"/>
213 <xsl:variable name="nop"><xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/@noParams"/></xsl:variable>
214 <xsl:for-each select="pattern">
215 <xsl:variable name="pos" select="position()"/>
216 <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>
218 <xsl:when test="$nopar = 0">
220 <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
225 <m:csymbol>app</m:csymbol>
227 <xsl:value-of select="document(concat(string($absPath),$Turi))/InductiveDefinition/InductiveType[position()=number($Tindex)+1]/Constructor[position()=number($pos)]/@name"/>
229 <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>
233 <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>
238 <xsl:template match="FIX" mode="pure">
239 <m:apply helm:xref="{@id}">
240 <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
241 <m:csymbol>fix</m:csymbol>
242 <m:ci><xsl:value-of select="FixFunction[position()=number($findex)+1]/@name"/></m:ci>
243 <xsl:apply-templates mode="pure" select="*"/>
247 <xsl:template match="COFIX" mode="pure">
248 <m:apply helm:xref="{@id}">
249 <xsl:variable name="findex"><xsl:value-of select="@noFun"/></xsl:variable>
250 <m:csymbol>cofix</m:csymbol>
251 <m:ci><xsl:value-of select="CofixFunction[position()=number($findex)+1]/@name"/></m:ci>
252 <xsl:apply-templates mode="pure" select="*"/>
256 <!-- ELEMENTS OF CIC TERMS -->
258 <xsl:template match="FixFunction" mode="pure">
260 <m:ci><xsl:value-of select="@name"/></m:ci>
261 <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
263 <xsl:apply-templates select="body/*[1]" mode="noannot"/>
266 <xsl:template match="CofixFunction" mode="pure">
268 <m:ci><xsl:value-of select="@name"/></m:ci>
269 <m:type><xsl:apply-templates select="type/*[1]" mode="noannot"/></m:type>
271 <xsl:apply-templates select="body/*[1]" mode="noannot"/>