3 <!--******************************************************************-->
4 <!-- XSLT version 0.1 of CIC objects to objects and MathML content: -->
5 <!-- First draft: March 21 2000, Irene Schena -->
6 <!--******************************************************************-->
8 <!--******************************************************************-->
9 <!-- MANCA: gestione annotation e linking -->
10 <!--******************************************************************-->
12 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13 xmlns:m="http://www.w3.org/1998/Math/MathML">
15 <xsl:import href="content.xsl"/>
19 <xsl:template match="cicxml">
20 <xsl:variable name="url"><xsl:value-of select="@baseurl"/></xsl:variable>
21 <xsl:variable name="stylesheet"><xsl:value-of select="@stylesheet"/></xsl:variable>
22 <xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>
23 <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select='concat($url,$stylesheet)'/>" type="text/xsl"</xsl:processing-instruction>
24 <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
25 <xsl:apply-templates/>
30 <xsl:template match="Definition" mode="noannot">
31 <Definition name="{@name}">
32 <xsl:if test="string(@params) != """>
34 <xsl:value-of select="@params"/>
38 <xsl:apply-templates select="body/*[1]">
39 <xsl:with-param name="backpointer" select=""*[1]""/>
40 </xsl:apply-templates>
43 <xsl:apply-templates select="type/*[1]">
44 <xsl:with-param name="backpointer" select=""*[2]""/>
45 </xsl:apply-templates>
50 <xsl:template match="Axiom" mode="noannot">
51 <Axiom name="{@name}">
52 <xsl:if test="string(@params) != """>
54 <xsl:value-of select="@params"/>
58 <xsl:apply-templates select="type"/>
63 <xsl:template match="CurrentProof" mode="noannot">
64 <CurrentProof name="{@name}">
65 <xsl:for-each select="Conjecture">
66 <Conjecture no="./{@no}">
67 <xsl:apply-templates select="."/>
71 <xsl:apply-templates select="body"/>
74 <xsl:apply-templates select="type"/>
79 <xsl:template match="InductiveDefinition" mode="noannot">
81 <xsl:if test="string(@params) != """>
83 <xsl:value-of select="@params"/>
86 <xsl:if test="string(@noParams) != 0">
87 <xsl:apply-templates select="InductiveType/arity/*[1]" mode="abstparams">
88 <xsl:with-param name="noparams" select="@noParams"/>
89 </xsl:apply-templates>
91 <xsl:for-each select="InductiveType">
92 <InductiveType name="{./@name}" inductive="{./@inductive}">
94 <xsl:apply-templates select="./arity/*[1]" mode="abstparams">
95 <xsl:with-param name="noparams" select="../@noParams"/>
96 <xsl:with-param name="target" select="1"/>
97 </xsl:apply-templates>
99 <xsl:for-each select="./Constructor">
100 <Constructor name="{./@name}">
101 <xsl:apply-templates select="./*[1]" mode="abstparams">
102 <xsl:with-param name="noparams" select="../../@noParams"/>
103 <xsl:with-param name="target" select="1"/>
104 </xsl:apply-templates>
109 </InductiveDefinition>
112 <xsl:template match="Variable" mode="noannot">
113 <Variable name="{@name}">
115 <xsl:apply-templates select="type"/>
120 <!--*******************************************-->
121 <!-- ABSTRACTING PARAMETERS AND COUNTING -->
122 <!--*******************************************-->
123 <!-- Si dimentica i CAST dei termini che astrae. Nel caso dell'astrazione -->
124 <!-- dei lambda dei pattern del CASE, qualora i lambda non si trovino -->
125 <!-- nella forma weak-head, astrae solo i lambda che trova e restituisce -->
126 <!-- un corpo depurato da tutti i primi cast che precedono il termine -->
129 <xsl:template match="*" mode="abstparams">
130 <xsl:param name="noparams" select="0"/>
131 <xsl:param name="target" select="0"/>
132 <xsl:param name="binder">PROD</xsl:param>
134 <xsl:when test="($noparams != 0) and ((name(.)=string($binder)) or (name(.)="CAST"))">
136 <xsl:when test="name(.) = string($binder)">
137 <xsl:if test="$target = 0">
139 <xsl:when test="string($binder) = "LAMBDA"">
141 <xsl:value-of select="target/@binder"/>
145 <Param name="{target/@binder}">
146 <xsl:apply-templates select="source" mode="noannot"/>
151 <xsl:apply-templates select="target/*[1]" mode="abstparams">
152 <xsl:with-param name="noparams" select="$noparams - 1"/>
153 <xsl:with-param name="target" select="$target"/>
154 <xsl:with-param name="binder" select="$binder"/>
155 </xsl:apply-templates>
158 <xsl:apply-templates select="term/*[1]" mode="abstparams">
159 <xsl:with-param name="noparams" select="$noparams"/>
160 <xsl:with-param name="target" select="$target"/>
161 <xsl:with-param name="binder" select="$binder"/>
162 </xsl:apply-templates>
168 <xsl:when test="($target = 1) and ($noparams != 0)">
170 <m:csymbol>app</m:csymbol>
171 <xsl:apply-templates select="." mode="noannot"/>
172 <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
177 <xsl:when test="$noparams != 0">
178 <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
181 <xsl:if test="$target = 1">
182 <xsl:apply-templates select="." mode="noannot"/>
192 <xsl:template name="printparam">
193 <xsl:param name="noleft" select="0"/>
194 <xsl:param name="number" select="1"/>
195 <xsl:if test="$noleft != 0">
196 <m:ci>$<xsl:value-of select="$number"/></m:ci>
197 <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noleft - 1"/><xsl:with-param name="number" select="$number + 1"/></xsl:call-template>
201 <xsl:template match="*" mode="counting">
202 <xsl:param name="noparams" select="0"/>
203 <xsl:param name="count" select="0"/>
205 <xsl:when test="name(.) = "PROD"">
206 <xsl:apply-templates select="target/*[1]" mode="counting">
207 <xsl:with-param name="noparams" select="$noparams"/>
208 <xsl:with-param name="count" select="$count + 1"/>
209 </xsl:apply-templates>
211 <xsl:when test="name(.) = "CAST"">
212 <xsl:apply-templates select="term/*[1]" mode="counting">
213 <xsl:with-param name="noparams" select="$noparams"/>
214 <xsl:with-param name="count" select="$count"/>
215 </xsl:apply-templates>
218 <xsl:value-of select="$count - $noparams"/>