]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/mathml_editor/xsl/tml-mmlp.xsl
debian release 0.0.4-1
[helm.git] / helm / DEVEL / mathml_editor / xsl / tml-mmlp.xsl
index 8b237387f4bc3bd4a99ca7de90bfc7bd87fecfde..8c9b8ead19ca45b35f138f5de16d0b900add3cc2 100644 (file)
@@ -3,6 +3,7 @@
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:tml="http://helm.cs.unibo.it/2002/TML"
      xmlns:m="http://www.w3.org/1998/Math/MathML"
+     exclude-result-prefixes="tml"
      version="1.0">
 
   <xsl:output indent="yes"/>
     </m:mo>
   </xsl:template>
 
-  <xsl:template match="tml:cursor">
+  <xsl:template match="tml:o[@val='-']">
+    <m:mo>
+      <xsl:if test="@id">
+        <xsl:attribute name="xref">
+          <xsl:value-of select="@id"/>
+        </xsl:attribute>
+      </xsl:if>
+      &#x2212;
+    </m:mo>
+  </xsl:template>
+
+  <xsl:template name="cursor">
     <xsl:choose>
       <xsl:when test="substring(@val,1,1)='\'">
         <m:mrow>
       </xsl:when>
       <xsl:otherwise>
         <m:mtext mathcolor="blue">
-          <xsl:if test="@id">
-            <xsl:attribute name="xref">
-              <xsl:value-of select="@id"/>
-            </xsl:attribute>
-          </xsl:if>
-         <xsl:value-of select="@val"/>
-       </m:mtext>
+         <xsl:if test="@id">
+           <xsl:attribute name="xref">
+             <xsl:value-of select="@id"/>
+           </xsl:attribute>
+         </xsl:if>I</m:mtext>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
 
+  <xsl:template match="tml:cursor[@visible='1']">
+    <xsl:param name="annotation" select="/.."/>
+    <xsl:choose>
+      <xsl:when test="$annotation">
+        <m:msub>
+         <xsl:call-template name="cursor"/>
+         <m:mtext>
+           <xsl:value-of select="$annotation"/>
+         </m:mtext>
+       </m:msub>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="cursor"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="tml:cursor[not(@visible) or @visible='0']">
+  </xsl:template>
+
   <xsl:template match="tml:sb[@under='1'][*[1]/tml:sp[@over='1']]">
     <m:munderover>
       <xsl:if test="@id">
         </xsl:attribute>
       </xsl:if>
       <xsl:apply-templates select="*[1]/*[1]"/>
-      <xsl:apply-templates select="*[1]"/>
+      <xsl:apply-templates select="*[2]"/>
       <xsl:apply-templates select="*[1]/*[2]"/>
     </m:msubsup>
   </xsl:template>
   </xsl:template>
 
   <xsl:template match="tml:g">
+    <xsl:param name="annotation" select="/.."/>
     <xsl:choose>
       <xsl:when test="not(@id) and count(*) = 1">
-        <xsl:apply-templates select="*[1]"/>
+        <xsl:apply-templates select="*[1]">
+         <xsl:with-param name="annotation" select="$annotation"/>
+       </xsl:apply-templates>
       </xsl:when>
       <xsl:when test="tml:cursor">
        <m:mstyle mathbackground="#e0e0e0">
             </xsl:attribute>
          </xsl:if>
          <m:mrow>
-           <xsl:apply-templates select="*"/>
+           <xsl:apply-templates select="*">
+             <xsl:with-param name="annotation" select="$annotation"/>
+           </xsl:apply-templates>
          </m:mrow>
        </m:mstyle>
       </xsl:when>
               <xsl:value-of select="@id"/>
             </xsl:attribute>
          </xsl:if>
-         <xsl:apply-templates select="*"/>
+         <xsl:apply-templates select="*">
+           <xsl:with-param name="annotation" select="$annotation"/>
+         </xsl:apply-templates>
        </m:mrow>
       </xsl:otherwise>
     </xsl:choose>
       </xsl:if>
       <xsl:apply-templates select="*[1]"/>
       <m:mo stretchy="true">&#x0305;</m:mo>
-    </m:mover>>
+    </m:mover>
   </xsl:template>
 
   <xsl:template match="tml:c[@name='underline']">
           <xsl:value-of select="@id"/>
         </xsl:attribute>
       </xsl:if>
-      <xsl:apply-templates select="*[2]"/>
-      <xsl:apply-templates select="*[1]"/>
+      <xsl:choose>
+        <xsl:when test="count(*) &lt; 2">
+         <m:mrow/>
+         <xsl:apply-templates select="*[1]"/>
+       </xsl:when>
+       <xsl:otherwise>
+          <xsl:apply-templates select="*[2]"/>
+          <xsl:apply-templates select="*[1]"/>
+       </xsl:otherwise>
+      </xsl:choose>
     </m:mroot>
   </xsl:template>
 
         </xsl:attribute>
       </xsl:if>
       <xsl:apply-templates select="*[1]"/>
+      <xsl:if test="tml:g/tml:cursor[@visible='1']">
+        <m:msub>
+          <m:mtext mathcolor="#808080">}</m:mtext>
+         <m:mtext><xsl:value-of select="@name"/></m:mtext>
+        </m:msub>
+      </xsl:if>
     </m:mstyle>
   </xsl:template>
 
     </m:mrow>
   </xsl:template>
 
+  <xsl:template match="tml:c[@name='red']">
+<!-- red  -->
+    <m:mstyle mathcolor="red">
+      <xsl:if test="@id">
+        <xsl:attribute name="xref">
+         <xsl:value-of select="@id"/>
+       </xsl:attribute>
+       <xsl:apply-templates/>
+      </xsl:if>
+    </m:mstyle>
+  </xsl:template>
+
+  <xsl:template match="tml:c[@name='green']">
+<!-- green  -->
+    <m:mstyle mathcolor="green">
+      <xsl:if test="@id">
+        <xsl:attribute name="xref">
+         <xsl:value-of select="@id"/>
+       </xsl:attribute>
+       <xsl:apply-templates/>
+      </xsl:if>
+    </m:mstyle>
+  </xsl:template>
+
+  <xsl:template match="tml:c[@name='duedelim']">
+<!-- duedelim  -->
+    <m:mfrac>
+      <xsl:if test="@id">
+        <xsl:attribute name="xref">
+          <xsl:value-of select="@id"/>
+        </xsl:attribute>
+      </xsl:if>
+      <xsl:apply-templates select="*[1]"/>
+      <xsl:apply-templates select="*[2]"/>
+    </m:mfrac>
+  </xsl:template>
+
 </xsl:stylesheet>