]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/nuprl_stylesheets/nuprl_link.xsl
First commit of the NuPRL stylesheets.
[helm.git] / helm / nuprl_stylesheets / nuprl_link.xsl
diff --git a/helm/nuprl_stylesheets/nuprl_link.xsl b/helm/nuprl_stylesheets/nuprl_link.xsl
new file mode 100644 (file)
index 0000000..849e06c
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version="1.0"?>
+
+<!-- Copyright (C) 2000, HELM Team                                     -->
+<!--                                                                   -->
+<!-- This file is part of HELM, an Hypertextual, Electronic            -->
+<!-- Library of Mathematics, developed at the Computer Science         -->
+<!-- Department, University of Bologna, Italy.                         -->
+<!--                                                                   -->
+<!-- HELM is free software; you can redistribute it and/or             -->
+<!-- modify it under the terms of the GNU General Public License       -->
+<!-- as published by the Free Software Foundation; either version 2    -->
+<!-- of the License, or (at your option) any later version.            -->
+<!--                                                                   -->
+<!-- HELM is distributed in the hope that it will be useful,           -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of    -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     -->
+<!-- GNU General Public License for more details.                      -->
+<!--                                                                   -->
+<!-- You should have received a copy of the GNU General Public License -->
+<!-- along with HELM; if not, write to the Free Software               -->
+<!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston,            -->
+<!-- MA  02111-1307, USA.                                              -->
+<!--                                                                   -->
+<!-- For details, see the HELM World-Wide-Web page,                    -->
+<!-- http://cs.unibo.it/helm/.                                         -->
+
+<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">
+
+<!--***********************************************************************--> 
+<!-- From MathML presentation or HTML to themselves with links             -->
+<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
+<!-- First draft: March 16 2001, Irene Schena                              -->
+<!--***********************************************************************--> 
+
+<xsl:import href="nuprl_links_library.xsl"/>
+
+<xsl:key name="id" use="@id" match="m:*"/>
+
+<xsl:param name="URLs_or_URIs" select="'URLs'"/>
+
+<xsl:template match = "m:semantics">
+   <xsl:apply-templates select="*[1]" mode="semantics"/>
+</xsl:template>
+
+<!-- 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:choose>
+       <xsl:when test="$URLs_or_URIs = 'URLs'">
+        <xsl:call-template name="makeURL"><xsl:with-param name="uri" select="$cnode/@definitionURL"/></xsl:call-template>
+       </xsl:when>
+       <xsl:otherwise>
+        <xsl:value-of select="$cnode/@definitionURL"/> 
+       </xsl:otherwise>
+      </xsl:choose>
+     </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>
+
+<!-- _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:choose>
+    <xsl:when test="starts-with(@href,&quot;nuprl:&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:template match = "/|*">
+  <xsl:copy>
+   <xsl:copy-of select="@*"/>
+   <xsl:apply-templates/>
+  </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet>