]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/style_prima_del_linguaggio_naturale/html_reals.xsl
Added style before natural language synthesis
[helm.git] / helm / style / style_prima_del_linguaggio_naturale / html_reals.xsl
diff --git a/helm/style/style_prima_del_linguaggio_naturale/html_reals.xsl b/helm/style/style_prima_del_linguaggio_naturale/html_reals.xsl
new file mode 100644 (file)
index 0000000..04ff478
--- /dev/null
@@ -0,0 +1,234 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                              xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!--***********************************************************************--> 
+<!-- INIT style for HTML                                                   -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
+<!--***********************************************************************--> 
+
+<xsl:variable name="absPath">http://localhost:8081/get?url=</xsl:variable>
+
+<!-- LIMIT -->
+
+<xsl:template match="m:apply[m:limit]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:limit/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:limit" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <xsl:text>lim</xsl:text>
+     </a>
+     <SUB>
+      <xsl:apply-templates select="m:bvar/m:ci"/>
+      <FONT FACE="symbol" color="blue">&#174;</FONT>
+      <xsl:apply-templates select="m:lowlimit"/>
+     </SUB>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 5"/> 
+     </xsl:call-template>
+     <xsl:apply-templates select="*[4]">
+      <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+     </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <xsl:text>lim</xsl:text>
+     </a>
+     <SUB>
+      <xsl:apply-templates select="m:bvar/m:ci"/>
+      <FONT FACE="symbol" color="blue">&#174;</FONT>
+      <xsl:apply-templates select="m:lowlimit"/>
+     </SUB>
+     <xsl:apply-templates select="*[4]">
+      <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+     </xsl:apply-templates>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- DIFFERENTIATION -->
+
+<xsl:template match="m:apply[m:diff]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:diff/@definitionURL"/>
+  </xsl:variable>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <SUP>d</SUP>
+      <xsl:text>/</xsl:text>
+     <SUB>
+      <xsl:text>d</xsl:text>
+      <xsl:value-of select="m:bvar/m:ci"/>
+     </SUB>
+     </a>
+     <xsl:apply-templates select="*[3]">
+      <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+     </xsl:apply-templates>
+ </xsl:template>
+
+<!-- ABSOLUTE VALUE -->
+<xsl:template match="m:apply[m:abs]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:abs/@definitionURL"/>
+  </xsl:variable>
+  <xsl:text>|</xsl:text>
+  <xsl:apply-templates select="*[2]">
+   <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+  </xsl:apply-templates>
+  <xsl:text>|</xsl:text>
+ </xsl:template>
+
+<!-- FACTORIAL -->
+
+<xsl:template match="m:apply[m:fact]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:abs/@definitionURL"/>
+  </xsl:variable>
+  <xsl:apply-templates select="*[2]">
+   <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+  </xsl:apply-templates>
+  <xsl:text>!</xsl:text>
+ </xsl:template>
+
+<!-- SQUARE ROOT -->
+
+<xsl:template match="m:apply[m:root]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:abs/@definitionURL"/>
+  </xsl:variable>
+  <xsl:text>(sqr</xsl:text>
+  <xsl:apply-templates select="*[2]">
+   <xsl:with-param name="current_indent" select="$current_indent + 5"/>
+  </xsl:apply-templates>
+  <xsl:text>)</xsl:text>
+ </xsl:template>
+
+<!-- POWER -->
+
+<xsl:template match="m:apply[m:power]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:power/@definitionURL"/>
+  </xsl:variable>
+  <xsl:apply-templates select="*[2]"/>
+  <SUP>
+  <xsl:apply-templates select="*[3]"/>
+  </SUP>
+ </xsl:template>
+
+<!-- MIN and MAX (binari: estendere) -->
+
+ <xsl:template match="m:apply[m:min|m:max]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="*[1]/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="*[1]" mode="charcount"/>
+  </xsl:variable>
+  <xsl:variable name="symbol">
+   <xsl:choose>
+    <xsl:when test="m:min">
+     <xsl:value-of select="'min'"/>
+    </xsl:when>
+    <xsl:when test="m:max">
+     <xsl:value-of select="'max'"/>
+    </xsl:when>
+   </xsl:choose>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <xsl:value-of select="$symbol"/>
+     </a>
+     <xsl:text>{</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <xsl:text>,</xsl:text>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 5"/> 
+     </xsl:call-template>
+     <xsl:apply-templates select="*[3]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <xsl:text>}</xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <xsl:value-of select="$symbol"/>
+     </a>
+     <xsl:text>{</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <xsl:text>, </xsl:text>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>}</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- COUNTING -->
+
+<xsl:template match="m:abs|m:fact|m:root
+           |m:limit|m:diff|m:min|m:max" mode="charcount">
+<xsl:param name="incurrent_length" select="0"/> 
+    <xsl:choose>
+    <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
+     <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
+     <xsl:choose>
+     <xsl:when test="string($siblength) = &quot;&quot;">
+      <xsl:value-of select="$incurrent_length + string-length()"/>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:value-of select="number($siblength)"/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:value-of select="$incurrent_length + string-length()"/>
+    </xsl:otherwise>
+    </xsl:choose>
+</xsl:template> 
+
+</xsl:stylesheet> 
+
+
+
+
+
+
+