]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/params.xsl
Modified Files:
[helm.git] / helm / style / params.xsl
index 034eeba978c574853e785f75d83990b596f68fbb..dc59df16752cbc61760e671058eeda0bbe1c39ac 100644 (file)
      </xsl:choose>
 </xsl:template>
 
+
+<!--***********************************************************************-->
+<!--  Insert a subscript if there is a number at the end of a ci element   -->
+<!--***********************************************************************-->
+
+<xsl:template name="insert_subscript">
+<xsl:param name="node_value" select="&quot;&quot;"/>
+<xsl:param name="current_pos" select="1"/>
+<xsl:param name="start_pos" select="0"/>
+    <xsl:choose>
+    <xsl:when test="$current_pos &lt;= string-length(string($node_value))">
+    <xsl:variable name="current_char"><xsl:value-of select="substring(string($node_value),$current_pos,1)"/></xsl:variable>
+     <xsl:choose>
+     <xsl:when test="(string($current_char) != &quot;0&quot;) and (string($current_char) != &quot;1&quot;) and (string($current_char) != &quot;2&quot;) and (string($current_char) != &quot;3&quot;) and (string($current_char) != &quot;4&quot;) and (string($current_char) != &quot;5&quot;) and (string($current_char) != &quot;6&quot;) and (string($current_char) !=  &quot;7&quot;) and (string($current_char) != &quot;8&quot;) and (string($current_char) != &quot;9&quot;)">
+      <xsl:choose> 
+      <xsl:when test="$start_pos != 0">
+       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="0"/></xsl:call-template>
+      </xsl:when> 
+      <xsl:otherwise>
+       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="$start_pos"/></xsl:call-template>
+      </xsl:otherwise>
+      </xsl:choose>
+     </xsl:when>
+     <xsl:otherwise>  
+      <xsl:choose>
+      <xsl:when test="$start_pos = 0">
+       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="$current_pos"/></xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="$start_pos"/></xsl:call-template>
+      </xsl:otherwise>
+      </xsl:choose>      
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:choose>
+     <xsl:when test="$start_pos != 0">
+      <m:msub>
+       <m:mi><xsl:value-of select="substring(string($node_value),1,$start_pos -1)"/></m:mi>
+       <m:mn><xsl:value-of select="substring(string($node_value),$start_pos)"/></m:mn>
+       </m:msub>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:value-of select="$node_value"/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:otherwise>    
+    </xsl:choose>
+</xsl:template>
+
+
 </xsl:stylesheet>