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"
14 xmlns:helm="http://www.cs.unibo.it/helm">
16 <xsl:import href="content.xsl"/>
20 <xsl:template match="cicxml">
21 <xsl:variable name="url"><xsl:value-of select="@baseurl"/></xsl:variable>
22 <xsl:variable name="stylesheet"><xsl:value-of select="@stylesheet"/></xsl:variable>
23 <xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>
24 <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select='concat($url,$stylesheet)'/>" type="text/xsl"</xsl:processing-instruction>
25 <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
26 <xsl:apply-templates select="*[1]"/>
31 <xsl:template match="Definition" mode="noannot">
32 <Definition name="{@name}" helm:xref="{@id}">
33 <xsl:if test="string(@params) != """>
35 <xsl:value-of select="@params"/>
39 <xsl:when test="$showproof=0">
46 <xsl:apply-templates select="body"/>
51 <xsl:apply-templates select="body/*"/>
54 <xsl:apply-templates select="type/*"/>
59 <xsl:template match="Axiom" mode="noannot">
60 <Axiom name="{@name}" helm:xref="{@id}">
61 <xsl:if test="string(@params) != """>
63 <xsl:value-of select="@params"/>
67 <xsl:apply-templates select="type/*"/>
72 <xsl:template match="CurrentProof" mode="noannot">
73 <CurrentProof name="{@name}" helm:xref="{@id}">
74 <xsl:for-each select="Conjecture">
75 <Conjecture no="./{@no}">
76 <xsl:apply-templates select="."/>
80 <xsl:apply-templates select="body/*"/>
83 <xsl:apply-templates select="type/*"/>
88 <xsl:template match="InductiveDefinition" mode="noannot">
89 <InductiveDefinition helm:xref="{@id}">
90 <xsl:if test="string(@params) != """>
92 <xsl:value-of select="@params"/>
95 <xsl:if test="string(@noParams) != 0">
96 <xsl:apply-templates select="InductiveType/arity/*[1]" mode="abstparams">
97 <xsl:with-param name="noparams" select="@noParams"/>
98 </xsl:apply-templates>
100 <xsl:for-each select="InductiveType">
101 <InductiveType name="{./@name}" inductive="{./@inductive}">
103 <xsl:apply-templates select="./arity/*[1]" mode="abstparams">
104 <xsl:with-param name="noparams" select="../@noParams"/>
105 <xsl:with-param name="target" select="1"/>
106 </xsl:apply-templates>
108 <xsl:for-each select="./Constructor">
109 <Constructor name="{./@name}">
110 <xsl:apply-templates select="./*[1]" mode="abstparams">
111 <xsl:with-param name="noparams" select="../../@noParams"/>
112 <xsl:with-param name="target" select="1"/>
113 </xsl:apply-templates>
118 </InductiveDefinition>
121 <xsl:template match="Variable" mode="noannot">
122 <Variable name="{@name}" helm:xref="{@id}">
124 <xsl:apply-templates select="type/*"/>
129 <!--*******************************************-->
130 <!-- ABSTRACTING PARAMETERS AND COUNTING -->
131 <!--*******************************************-->
132 <!-- Si dimentica i CAST dei termini che astrae. Nel caso dell'astrazione -->
133 <!-- dei lambda dei pattern del CASE, qualora i lambda non si trovino -->
134 <!-- nella forma weak-head, astrae solo i lambda che trova e restituisce -->
135 <!-- un corpo depurato da tutti i primi cast che precedono il termine -->
138 <xsl:template match="*" mode="abstparams">
139 <xsl:param name="noparams" select="0"/>
140 <xsl:param name="target" select="0"/>
141 <xsl:param name="binder">PROD</xsl:param>
143 <xsl:when test="($noparams != 0) and ((name(.)=string($binder)) or (name(.)="CAST"))">
145 <xsl:when test="name(.) = string($binder)">
146 <xsl:if test="$target = 0">
148 <xsl:when test="string($binder) = "LAMBDA"">
150 <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
154 <Param name="{target/@binder}">
155 <xsl:apply-templates select="source" mode="noannot"/>
160 <xsl:apply-templates select="target/*[1]" mode="abstparams">
161 <xsl:with-param name="noparams" select="$noparams - 1"/>
162 <xsl:with-param name="target" select="$target"/>
163 <xsl:with-param name="binder" select="$binder"/>
164 </xsl:apply-templates>
167 <xsl:apply-templates select="term/*[1]" mode="abstparams">
168 <xsl:with-param name="noparams" select="$noparams"/>
169 <xsl:with-param name="target" select="$target"/>
170 <xsl:with-param name="binder" select="$binder"/>
171 </xsl:apply-templates>
177 <xsl:when test="($target = 1) and ($noparams != 0)">
179 <m:csymbol>app</m:csymbol>
180 <xsl:apply-templates select="." mode="noannot"/>
181 <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
186 <xsl:when test="$noparams != 0">
187 <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
190 <xsl:if test="$target = 1">
191 <xsl:apply-templates select="." mode="noannot"/>
201 <xsl:template name="printparam">
202 <xsl:param name="noleft" select="0"/>
203 <xsl:param name="number" select="1"/>
204 <xsl:if test="$noleft != 0">
205 <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value">$<xsl:value-of select="$number"/></xsl:with-param></xsl:call-template></m:ci>
206 <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noleft - 1"/><xsl:with-param name="number" select="$number + 1"/></xsl:call-template>
210 <xsl:template match="*" mode="counting">
211 <xsl:param name="noparams" select="0"/>
212 <xsl:param name="count" select="0"/>
214 <xsl:when test="name(.) = "PROD"">
215 <xsl:apply-templates select="target/*[1]" mode="counting">
216 <xsl:with-param name="noparams" select="$noparams"/>
217 <xsl:with-param name="count" select="$count + 1"/>
218 </xsl:apply-templates>
220 <xsl:when test="name(.) = "CAST"">
221 <xsl:apply-templates select="term/*[1]" mode="counting">
222 <xsl:with-param name="noparams" select="$noparams"/>
223 <xsl:with-param name="count" select="$count"/>
224 </xsl:apply-templates>
227 <xsl:value-of select="$count - $noparams"/>