]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/annotatedcont.xsl
Initial revision
[helm.git] / helm / style / annotatedcont.xsl
diff --git a/helm/style/annotatedcont.xsl b/helm/style/annotatedcont.xsl
new file mode 100644 (file)
index 0000000..e97d08f
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+
+<!--***********************************************************************--> 
+<!-- XSLT version 0.1 of annotated MathML content to MathML presentation:  -->
+<!-- First draft: March 29 2000, Claudio Sacerdoti Coen, Irene Schena      -->
+<!--***********************************************************************--> 
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                              xmlns:m="http://www.w3.org/1998/Math/MathML"
+                              xmlns:helm="http://www.cs.unibo.it/helm">
+
+<xsl:import href="objcontent.xsl"/>
+
+<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"/>
+
+<xsl:key name="annid" use="@of" match="Annotation"/>
+
+<xsl:template match="Definition|Axiom|CurrentProof|InductiveDefinition|Variable">
+    <xsl:choose>
+    <xsl:when test="key('annid',@id)">
+     <annotation helm:xref="{@id}">
+      <xsl:apply-templates select="key('annid',@id)"/>
+     </annotation>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:apply-templates select="." mode="noannot"/>
+    </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX">
+    <xsl:choose>
+    <xsl:when test="key('annid',@id)">
+     <annotation helm:xref="{@id}">
+      <xsl:apply-templates select="key('annid',@id)"/>
+     </annotation>
+    </xsl:when>
+    <xsl:otherwise>
+     <m:math>
+      <xsl:apply-templates select="." mode="noannot"/>
+     </m:math>
+    </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template match="node">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:apply-templates select="key('id',$id)"/>
+</xsl:template>
+
+<xsl:template match="attribute">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="name" select="@name"/>
+ <xsl:variable name="child" select="@child"/>
+ <xsl:variable name="grandchild" select="@grandchild"/>
+ <xsl:choose>
+  <xsl:when test="$child">
+   <xsl:choose>
+    <xsl:when test="$grandchild">
+     <xsl:value-of select="key('id',$id)/*[position() = $child]/*[position() = $grandchild]/attribute::*[name() = $name]"/>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:value-of select="key('id',$id)/*[position() = $child]/attribute::*[name() = $name]"/>
+    </xsl:otherwise>
+   </xsl:choose>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:value-of select="key('id',$id)/attribute::*[name() = $name]"/>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>