]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/html_set.xsl
Initial revision
[helm.git] / helm / style / html_set.xsl
diff --git a/helm/style/html_set.xsl b/helm/style/html_set.xsl
new file mode 100644 (file)
index 0000000..6c7f66b
--- /dev/null
@@ -0,0 +1,463 @@
+<?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>
+
+<!-- IN -->
+
+ <xsl:template match="m:apply[m:in]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:in/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:in" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#206;</FONT>
+     </a>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#206;</FONT>
+     </a>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- NOTIN -->
+
+ <xsl:template match="m:apply[m:notin]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:notin/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:notin" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#207;</FONT>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#207;</FONT>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- SET -->
+
+ <xsl:template match="m:set">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="concat(string($absPath), @definitionURL)"/>
+  </xsl:variable>
+  <xsl:choose>
+   <xsl:when test="count(child::*) = 0">
+    <FONT FACE="symbol" color="blue">&#198;</FONT>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:variable name="charlength">
+     <xsl:apply-templates select="." mode="charcount"/>
+    </xsl:variable>
+    <xsl:choose>
+     <xsl:when test="name(*[1]) = 'm:bvar'">
+      <xsl:choose>
+       <xsl:when test="$charlength > $framewidth">
+        <xsl:text>{</xsl:text>
+        <xsl:apply-templates select="m:bvar/m:ci"/>
+        <xsl:text>:</xsl:text>
+        <xsl:apply-templates select="m:bvar/m:type">
+         <xsl:with-param name="current_indent" 
+           select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
+        </xsl:apply-templates><BR/>
+        <xsl:call-template name="make_indent">
+         <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+        </xsl:call-template>
+        <xsl:text>|</xsl:text>
+        <xsl:apply-templates select="m:condition">
+         <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+        </xsl:apply-templates>
+        <xsl:text>}</xsl:text>
+       </xsl:when>
+       <xsl:otherwise>
+        <xsl:text>{</xsl:text>
+        <xsl:apply-templates select="m:bvar/m:ci"/>
+        <xsl:text>:</xsl:text>
+        <xsl:apply-templates select="m:bvar/m:type"/>
+        <xsl:text>|</xsl:text>
+        <xsl:apply-templates select="*[position()=2]"/>
+        <xsl:text>}</xsl:text>
+       </xsl:otherwise>
+      </xsl:choose>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:choose>
+       <xsl:when test="$charlength > $framewidth">
+        <xsl:text>{</xsl:text>
+         <xsl:apply-templates select="*[position()=1]">
+          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+         </xsl:apply-templates>
+         <xsl:for-each select="*[position()>1]">
+          <xsl:text>,</xsl:text>
+          <BR/>
+          <xsl:call-template name="make_indent">
+           <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+          </xsl:call-template>
+          <xsl:apply-templates select=".">
+           <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+          </xsl:apply-templates>
+         </xsl:for-each>
+         <xsl:text>}</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+        <xsl:text>{</xsl:text>
+         <xsl:for-each select="*">
+          <xsl:apply-templates select="."/>
+          <xsl:choose>
+           <xsl:when test="position() = last()">
+            <xsl:text>}</xsl:text>
+           </xsl:when>
+           <xsl:otherwise>
+            <xsl:text>,</xsl:text>
+           </xsl:otherwise>
+          </xsl:choose>
+         </xsl:for-each>
+        </xsl:otherwise>
+       </xsl:choose>
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+
+<!-- INTERSECTION -->
+
+<xsl:template match="m:apply[m:intersect]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:intersect/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:intersect" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#199;</FONT>
+     </a>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#199;</FONT>
+     </a>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- UNION -->
+
+<xsl:template match="m:apply[m:union]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:union/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:union" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#200;</FONT>
+     </a>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#200;</FONT>
+     </a>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- SUBSET -->
+<xsl:template match="m:apply[m:subset]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:subset/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:subset" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#205;</FONT>
+     </a>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#205;</FONT>
+     </a>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- PRSUBSET -->
+<xsl:template match="m:apply[m:prsubset]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:prsubset/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:prsubset" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#204;</FONT>
+     </a>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <FONT FACE="symbol" SIZE="+2" color="blue">&#204;</FONT>
+     </a>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+
+<!-- SETDIFF -->
+
+<xsl:template match="m:apply[m:setdiff]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:setdiff/@definitionURL"/>
+  </xsl:variable>
+  <xsl:variable name="charlength">
+   <xsl:apply-templates select="m:setdiff" mode="charcount"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$charlength > $framewidth">
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
+     </xsl:apply-templates>
+     <BR/> 
+     <xsl:call-template name="make_indent">
+      <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
+     </xsl:call-template>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <xsl:text>/</xsl:text>
+     </a>
+     <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>
+     <xsl:text>(</xsl:text>
+     <xsl:apply-templates select="*[2]"/>
+     <a>
+     <xsl:attribute name="href">
+      <xsl:value-of select="concat(string($header),string($uri))"/>
+     </xsl:attribute>
+     <xsl:text>/</xsl:text>
+     </a>
+     <xsl:apply-templates select="*[3]"/>
+     <xsl:text>)</xsl:text>
+    </xsl:otherwise>
+   </xsl:choose>
+ </xsl:template>
+
+<!-- CARD -->
+<xsl:template match="m:apply[m:card]">
+  <xsl:param name="current_indent" select="0"/> 
+  <xsl:param name="width" select="$framewidth"/>
+  <xsl:variable name="uri">
+   <xsl:value-of select="m:card/@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>
+
+<!-- COUNTING -->
+
+<xsl:template match="m:in|m:notin|m:intersect|m:union
+           |m:subset|m:prsubset|m:setdiff|m:card" 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> 
+
+
+
+
+
+
+