]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/link.xsl
Initial revision
[helm.git] / helm / style / link.xsl
index ad974012bc4fa09a51d48ab044b8ebcf84a9b6e4..e3568a18ffb386ca03acc26471127570a4115197 100644 (file)
@@ -26,6 +26,7 @@
 
 <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"
                               xmlns:xlink="http://www.w3.org/1999/xlink">
 
 <!--***********************************************************************--> 
 <!-- First draft: March 16 2001, Irene Schena                              -->
 <!--***********************************************************************--> 
 
-<xsl:param name="getterURL" select="'http://localhost:8081/'"/>
-<xsl:param name="processorURL" select="'http://localhost:8080/helm/servlet/uwobo/'"/>
-<xsl:param name="keys" select="'C1,HC2'"/>
-<xsl:param name="naturalLanguage" select="'yes'"/>
-<xsl:param name="annotations" select="'no'"/>
-<xsl:param name="media-type" select="'text/html'"/>
-<xsl:param name="doctype-public" select="'-//W3C//DTD XHTML 1.0 Transitional//EN'"/>
-<xsl:param name="encoding" select="iso-8859-1"/>
+<xsl:import href="links_library.xsl"/>
 
-<xsl:variable name="absPath"><xsl:value-of select="$getterURL"/>getxml?uri=</xsl:variable>
+<xsl:key name="id" use="@id" match="m:*"/>
 
-<xsl:variable name="header"><xsl:value-of select="$processorURL"/>apply?keys=<xsl:value-of select="$keys"/>&#x26;param.naturalLanguage=<xsl:value-of select="$naturalLanguage"/>&#x26;param.annotations=<xsl:value-of select="$annotations"/>&#x26;prop.media-type=<xsl:value-of select="$media-type"/>&#x26;prop.doctype-public=<xsl:value-of select="$doctype-public"/>&#x26;prop.encoding=<xsl:value-of select="$encoding"/>&#x26;param.keys=<xsl:value-of select="$keys"/>&#x26;param.getterURL=<xsl:value-of select="$getterURL"/>&#x26;param.processorURL=<xsl:value-of select="$processorURL"/>&#x26;xmluri=<xsl:value-of select="$absPath"/></xsl:variable>
-
-<xsl:template name="makeURL">
-<xsl:param name="uri" select="''"/>
-    <xsl:value-of select="concat(string($header),string($uri),'&#x26;param.CICURI=',string($uri))"/>
+<xsl:template match = "m:semantics">
+   <xsl:apply-templates select="*[1]" mode="semantics"/>
 </xsl:template>
 
-<xsl:template match="*[@xlink:href]">
- <xsl:copy>
-    <xsl:copy-of select="@*"/>
-    <xsl:attribute name="xlink:href">
-     <xsl:call-template name="makeURL">
-      <xsl:with-param name="uri" select="@xlink:href"/>
-     </xsl:call-template>
-    </xsl:attribute>
-    <xsl:apply-templates/>
- </xsl:copy>
+<!-- Discharging content markup mantaining the linking info (helm:xref and 
+xlink:href) -->
+<xsl:template match = "*" mode="semantics">
+  <xsl:copy>
+   <xsl:copy-of select="@*"/>
+   <xsl:if test="@xref">
+    <xsl:variable name="cnode" select="key('id',@xref)"/>
+    <xsl:if test="$cnode/@definitionURL"> 
+     <xsl:attribute name="xlink:href">
+      <xsl:call-template name="makeURL"><xsl:with-param name="uri" select="$cnode/@definitionURL"/></xsl:call-template>
+     </xsl:attribute>
+    <!-- xlink:show='other' requires the exact modality to be -->
+    <!-- specified in non-xlink markup. The point is that the -->
+    <!-- element is already MathML ==> we can't add other     -->
+    <!-- markup without introducing another new namespace.    -->
+    <!-- So, for now no markup is used.                       -->
+     <xsl:attribute name="xlink:show">other</xsl:attribute>
+    </xsl:if>
+    <xsl:if test="$cnode/@helm:xref">
+     <xsl:attribute name="helm:xref">
+      <xsl:value-of select="$cnode/@helm:xref"/>
+     </xsl:attribute>
+    </xsl:if> 
+   </xsl:if>
+   <xsl:apply-templates mode="semantics"/>
+  </xsl:copy>
 </xsl:template>
 
-<xsl:template match="a[@href]">
+<!-- _top to refresh the whole frameset (avoids the matrioska effect ;-) -->
+<!-- a[@href] doesn't match with every anchor elements!!!                -->
+<xsl:template match="*[@href]">
    <xsl:copy>
     <xsl:copy-of select="@*"/> 
-    <xsl:attribute name="href">
-     <xsl:call-template name="makeURL">
-      <xsl:with-param name="uri" select="@href"/>
-     </xsl:call-template>
-    </xsl:attribute>
+    <xsl:choose>
+    <xsl:when test="starts-with(@href,&quot;cic:&quot;)">
+     <xsl:attribute name="href">
+      <xsl:call-template name="makeURL">
+       <xsl:with-param name="uri" select="@href"/>
+      </xsl:call-template>
+     </xsl:attribute>
+     <xsl:attribute name="target">cic</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="starts-with(@href,&quot;theory:&quot;)">
+     <xsl:attribute name="href">
+      <xsl:call-template name="makeTheoryURL">
+       <xsl:with-param name="uri" select="@href"/>
+      </xsl:call-template>
+     </xsl:attribute>
+     <xsl:attribute name="target">theory</xsl:attribute>
+    </xsl:when>
+    <xsl:when test="starts-with(@href,&quot;#&quot;)">
+     <xsl:attribute name="href"><xsl:value-of  select="@href"/></xsl:attribute>
+     <xsl:if test="@target">
+      <xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
+     </xsl:if>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:attribute name="href"><xsl:value-of  select="@href"/></xsl:attribute>
+     <xsl:attribute name="target">_blank</xsl:attribute>
+    </xsl:otherwise>
+    </xsl:choose>
     <xsl:apply-templates/>
    </xsl:copy>
 </xsl:template>
   </xsl:copy>
 </xsl:template>
 
-</xsl:stylesheet> 
\ No newline at end of file
+</xsl:stylesheet>