]> matita.cs.unibo.it Git - helm.git/blob - helm/style/annotatedcont.xsl
Initial revision
[helm.git] / helm / style / annotatedcont.xsl
1 <?xml version="1.0"?>
2
3 <!--***********************************************************************--> 
4 <!-- XSLT version 0.1 of annotated MathML content to MathML presentation:  -->
5 <!-- First draft: March 29 2000, Claudio Sacerdoti Coen, Irene Schena      -->
6 <!--***********************************************************************--> 
7
8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9                               xmlns:m="http://www.w3.org/1998/Math/MathML"
10                               xmlns:helm="http://www.cs.unibo.it/helm">
11
12 <xsl:import href="objcontent.xsl"/>
13
14 <xsl:key name="id" use="@id" match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX|Definition|Axiom|CurrentProof|InductiveDefinition|Variable"/>
15
16 <xsl:key name="annid" use="@of" match="Annotation"/>
17
18 <xsl:template match="Definition|Axiom|CurrentProof|InductiveDefinition|Variable">
19     <xsl:choose>
20     <xsl:when test="key('annid',@id)">
21      <annotation helm:xref="{@id}">
22       <xsl:apply-templates select="key('annid',@id)"/>
23      </annotation>
24     </xsl:when>
25     <xsl:otherwise>
26      <xsl:apply-templates select="." mode="noannot"/>
27     </xsl:otherwise>
28     </xsl:choose>
29 </xsl:template>
30
31 <xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX">
32     <xsl:choose>
33     <xsl:when test="key('annid',@id)">
34      <annotation helm:xref="{@id}">
35       <xsl:apply-templates select="key('annid',@id)"/>
36      </annotation>
37     </xsl:when>
38     <xsl:otherwise>
39      <m:math>
40       <xsl:apply-templates select="." mode="noannot"/>
41      </m:math>
42     </xsl:otherwise>
43     </xsl:choose>
44 </xsl:template>
45
46 <xsl:template match="node">
47  <xsl:variable name="id" select="@id"/>
48  <xsl:apply-templates select="key('id',$id)"/>
49 </xsl:template>
50
51 <xsl:template match="attribute">
52  <xsl:variable name="id" select="@id"/>
53  <xsl:variable name="name" select="@name"/>
54  <xsl:variable name="child" select="@child"/>
55  <xsl:variable name="grandchild" select="@grandchild"/>
56  <xsl:choose>
57   <xsl:when test="$child">
58    <xsl:choose>
59     <xsl:when test="$grandchild">
60      <xsl:value-of select="key('id',$id)/*[position() = $child]/*[position() = $grandchild]/attribute::*[name() = $name]"/>
61     </xsl:when>
62     <xsl:otherwise>
63      <xsl:value-of select="key('id',$id)/*[position() = $child]/attribute::*[name() = $name]"/>
64     </xsl:otherwise>
65    </xsl:choose>
66   </xsl:when>
67   <xsl:otherwise>
68    <xsl:value-of select="key('id',$id)/attribute::*[name() = $name]"/>
69   </xsl:otherwise>
70  </xsl:choose>
71 </xsl:template>
72
73 </xsl:stylesheet>