]> matita.cs.unibo.it Git - helm.git/blob - helm/style/objcontent.xsl
Variable redefined twice fixed.
[helm.git] / helm / style / objcontent.xsl
1 <?xml version="1.0"?>
2
3 <!-- Copyright (C) 2000, HELM Team                                     -->
4 <!--                                                                   -->
5 <!-- This file is part of HELM, an Hypertextual, Electronic            -->
6 <!-- Library of Mathematics, developed at the Computer Science         -->
7 <!-- Department, University of Bologna, Italy.                         -->
8 <!--                                                                   -->
9 <!-- HELM is free software; you can redistribute it and/or             -->
10 <!-- modify it under the terms of the GNU General Public License       -->
11 <!-- as published by the Free Software Foundation; either version 2    -->
12 <!-- of the License, or (at your option) any later version.            -->
13 <!--                                                                   -->
14 <!-- HELM is distributed in the hope that it will be useful,           -->
15 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of    -->
16 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     -->
17 <!-- GNU General Public License for more details.                      -->
18 <!--                                                                   -->
19 <!-- You should have received a copy of the GNU General Public License -->
20 <!-- along with HELM; if not, write to the Free Software               -->
21 <!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston,            -->
22 <!-- MA  02111-1307, USA.                                              -->
23 <!--                                                                   -->
24 <!-- For details, see the HELM World-Wide-Web page,                    -->
25 <!-- http://cs.unibo.it/helm/.                                         -->
26
27 <!--******************************************************************--> 
28 <!-- XSLT version 0.1 of CIC objects to objects and MathML content:   -->
29 <!-- First draft: March 21 2000, Irene Schena                         -->
30 <!--******************************************************************-->
31
32 <!--******************************************************************-->
33 <!-- MANCA: gestione annotation e linking                             -->
34 <!--******************************************************************-->
35
36 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37                               xmlns:m="http://www.w3.org/1998/Math/MathML"
38                               xmlns:helm="http://www.cs.unibo.it/helm">
39
40 <xsl:import href="content.xsl"/>
41
42 <!-- ROOT -->
43
44 <xsl:template match="cicxml">
45     <xsl:variable name="url"><xsl:value-of select="@baseurl"/></xsl:variable>
46     <xsl:variable name="stylesheet"><xsl:value-of select="@stylesheet"/></xsl:variable>
47     <!--
48     <xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>
49     <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select='concat($url,$stylesheet)'/>" type="text/xsl"</xsl:processing-instruction>
50     <xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
51     -->
52     <xsl:apply-templates select="*[1]"/>
53 </xsl:template>
54
55
56 <!-- FUNZIONI AUSILIARIE -->
57
58 <xsl:template name="name_of_uri_bis">
59  <xsl:param name="uri" select="&quot;&quot;"/>
60   <xsl:variable name="suffix" select="substring-after($uri, &quot;/&quot;)"/>
61   <xsl:choose>
62    <xsl:when test="$suffix = &quot;&quot;">
63     <xsl:value-of select="substring-before($uri,&quot;.var&quot;)"/>
64    </xsl:when>
65    <xsl:otherwise>
66     <xsl:call-template name="name_of_uri_bis">
67      <xsl:with-param name="uri" select="$suffix"/>
68     </xsl:call-template>
69    </xsl:otherwise>
70   </xsl:choose>
71 </xsl:template>
72
73 <xsl:template name="var_name">
74  <xsl:param name="uri"/>
75  <xsl:param name="string" select="&quot;&quot;"/>
76   <xsl:variable name="prefix0" select="substring-before($uri, &quot; &quot;)"/>
77   <xsl:variable name="suffix" select="substring-after($uri, &quot; &quot;)"/> 
78   <xsl:variable name="prefix">
79    <xsl:call-template name="name_of_uri_bis">
80     <xsl:with-param name="uri" select="$prefix0"/>
81    </xsl:call-template>
82   </xsl:variable> 
83   <!--xsl:if test="string($prefix) != &quot; &quot; "-->
84    <xsl:variable name="string" select="concat($string,', ', $prefix)"/>
85   <!--/xsl:if-->
86   <xsl:choose>
87    <xsl:when test="$suffix = &quot;&quot;">
88    <xsl:value-of select="substring-after(concat($string, ' '),',')"/>
89    </xsl:when>
90    <xsl:otherwise>
91    <xsl:call-template name="var_name">
92     <xsl:with-param name="uri" select="$suffix"/>
93     <xsl:with-param name="string" select="$string"/>
94    </xsl:call-template>
95    </xsl:otherwise>
96   </xsl:choose>
97 </xsl:template>
98                                   
99                                   
100 <!-- CIC OBJECTS -->
101
102 <xsl:template match="Sequent">  <!-- For Sequents there are no annotations --> 
103     <Sequent helm:xref="{@id}" no="{@no}">
104      <xsl:for-each select="Decl|Def|Hidden">
105       <xsl:copy>
106        <xsl:attribute name="name">
107         <xsl:value-of select="@name"/>
108        </xsl:attribute>
109        <xsl:attribute name="helm:xref">
110         <xsl:value-of select="@id"/>
111        </xsl:attribute>
112        <xsl:apply-templates select="*[1]"/>
113       </xsl:copy>
114      </xsl:for-each>
115      <Goal>
116       <xsl:apply-templates select="Goal/*[1]"/>
117      </Goal>
118     </Sequent> 
119 </xsl:template>
120
121 <xsl:template match="ConstantType" mode="noannot">
122     <xsl:variable name="ConstantBodyUrl" 
123                   select="concat($BaseCICURI,'.body')"/>
124     <Definition name="{@name}" helm:xref="{@id}">  
125      <xsl:if test="string(@params) != &quot;&quot;">
126       <Params>
127       <xsl:call-template name="var_name">
128        <xsl:with-param name="uri" select="concat(@params, ' ')"/>
129       </xsl:call-template>
130       </Params>
131      </xsl:if>
132 <!--     <xsl:choose>
133       <xsl:when test="$showproof=0">
134        <body>
135         <m:mi>Here</m:mi>
136        </body>
137       </xsl:when>
138       <xsl:otherwise>
139        <body>
140         <xsl:apply-templates select="body"/>
141        </body>
142       </xsl:otherwise>
143      </xsl:choose> -->
144      <body>
145       <m:ci definitionURL="{$ConstantBodyUrl}">click here</m:ci>
146      </body>
147      <type>
148        <xsl:apply-templates select="./*[1]"/>
149      </type>
150     </Definition> 
151 </xsl:template>
152
153 <xsl:template match="ConstantBody" mode= "noannot">
154     <Definition name="{@for}" helm:xref="{@id}">  
155      <xsl:if test="string(@params) != &quot;&quot;">
156       <Params>
157        <xsl:call-template name="var_name">
158        <xsl:with-param name="uri" select="concat(@params, ' ')"/>
159        </xsl:call-template>
160       </Params>
161      </xsl:if>
162      <body>
163       <xsl:apply-templates select="./*[1]"/>
164      </body>
165      <type>
166        <xsl:apply-templates select="document($ConstantTypeUrl)/*[1]/*[1]"/>
167      </type>
168     </Definition>
169 </xsl:template>
170
171
172 <xsl:template match="CurrentProof" mode="noannot">
173     <CurrentProof name="{@of}" helm:xref="{@id}">
174      <xsl:for-each select="Conjecture">
175       <Conjecture no="{@no}" helm:xref="{@id}">
176         <xsl:for-each select="*">
177          <xsl:copy>
178           <xsl:copy-of select="@name"/>
179           <xsl:attribute name="helm:xref">
180            <xsl:value-of select="@id"/>
181           </xsl:attribute>
182           <xsl:apply-templates select="*"/>
183          </xsl:copy>
184         </xsl:for-each>
185       </Conjecture>
186      </xsl:for-each>
187      <body>
188        <xsl:apply-templates select="body/*[1]"/>
189      </body>
190      <type>
191        <xsl:apply-templates select="document($ConstantTypeUrl)/*[1]/*[1]"/>
192      </type>
193     </CurrentProof> 
194 </xsl:template>
195
196 <xsl:template match="InductiveDefinition" mode="noannot">
197     <InductiveDefinition helm:xref="{@id}">
198      <xsl:if test="string(@params) != &quot;&quot;">
199       <Params>
200        <xsl:value-of select="@params"/>
201       </Params>
202      </xsl:if> 
203      <xsl:if test="string(@noParams) != 0"> 
204       <xsl:apply-templates select="InductiveType/arity/*[1]" mode="abstparams">
205        <xsl:with-param name="noparams" select="@noParams"/>
206       </xsl:apply-templates>
207      </xsl:if>
208      <xsl:for-each select="InductiveType">
209       <InductiveType name="{./@name}" inductive="{./@inductive}">
210        <arity>
211          <xsl:apply-templates select="./arity/*[1]" mode="abstparams">
212           <xsl:with-param name="noparams" select="../@noParams"/>
213           <xsl:with-param name="target" select="1"/>
214          </xsl:apply-templates>
215        </arity>
216        <xsl:for-each select="./Constructor">
217         <Constructor name="{./@name}">
218           <xsl:apply-templates select="./*[1]" mode="abstparams">
219            <xsl:with-param name="noparams" select="../../@noParams"/>
220            <xsl:with-param name="target" select="1"/>
221           </xsl:apply-templates>
222         </Constructor>
223        </xsl:for-each>
224       </InductiveType>
225      </xsl:for-each> 
226     </InductiveDefinition>       
227 </xsl:template>
228
229 <xsl:template match="Variable" mode="noannot"> 
230     <Variable name="{@name}" helm:xref="{@id}">
231      <xsl:if test="name(*[1])='body'">
232       <body>
233        <xsl:apply-templates select="body/*[1]"/>
234       </body>
235      </xsl:if>
236      <type>
237        <xsl:apply-templates select="type/*[1]"/>
238      </type>
239     </Variable> 
240 </xsl:template>
241
242 </xsl:stylesheet>