]> matita.cs.unibo.it Git - helm.git/blob - helm/nuprl_stylesheets/nuprl_link.xsl
ocaml 3.09 transition
[helm.git] / helm / nuprl_stylesheets / nuprl_link.xsl
1 <?xml version="1.0"?>
2
3 <!-- Copyright (C) 2000, HELM Team                                     -->
4 <!--                                                                   -->
5 <!-- This file is part of HELM, an Hypertextual, Electronic            -->
6 <!-- Library of Mathematics, developed at the Computer Science         -->
7 <!-- Department, University of Bologna, Italy.                         -->
8 <!--                                                                   -->
9 <!-- HELM is free software; you can redistribute it and/or             -->
10 <!-- modify it under the terms of the GNU General Public License       -->
11 <!-- as published by the Free Software Foundation; either version 2    -->
12 <!-- of the License, or (at your option) any later version.            -->
13 <!--                                                                   -->
14 <!-- HELM is distributed in the hope that it will be useful,           -->
15 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of    -->
16 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     -->
17 <!-- GNU General Public License for more details.                      -->
18 <!--                                                                   -->
19 <!-- You should have received a copy of the GNU General Public License -->
20 <!-- along with HELM; if not, write to the Free Software               -->
21 <!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston,            -->
22 <!-- MA  02111-1307, USA.                                              -->
23 <!--                                                                   -->
24 <!-- For details, see the HELM World-Wide-Web page,                    -->
25 <!-- http://cs.unibo.it/helm/.                                         -->
26
27 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28                               xmlns:m="http://www.w3.org/1998/Math/MathML"
29                               xmlns:helm="http://www.cs.unibo.it/helm"
30                               xmlns:xlink="http://www.w3.org/1999/xlink">
31
32 <!--***********************************************************************--> 
33 <!-- From MathML presentation or HTML to themselves with links             -->
34 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
35 <!-- First draft: March 16 2001, Irene Schena                              -->
36 <!--***********************************************************************--> 
37
38 <xsl:import href="nuprl_links_library.xsl"/>
39
40 <xsl:key name="id" use="@id" match="m:*"/>
41
42 <xsl:param name="URLs_or_URIs" select="'URLs'"/>
43
44 <xsl:template match = "m:semantics">
45    <xsl:apply-templates select="*[1]" mode="semantics"/>
46 </xsl:template>
47
48 <!-- Discharging content markup mantaining the linking info (helm:xref and 
49 xlink:href) -->
50 <xsl:template match = "*" mode="semantics">
51   <xsl:copy>
52    <xsl:copy-of select="@*"/>
53    <xsl:if test="@xref">
54     <xsl:variable name="cnode" select="key('id',@xref)"/>
55     <xsl:if test="$cnode/@definitionURL"> 
56      <xsl:attribute name="xlink:href">
57       <xsl:choose>
58        <xsl:when test="$URLs_or_URIs = 'URLs'">
59         <xsl:call-template name="makeURL"><xsl:with-param name="uri" select="$cnode/@definitionURL"/></xsl:call-template>
60        </xsl:when>
61        <xsl:otherwise>
62         <xsl:value-of select="$cnode/@definitionURL"/> 
63        </xsl:otherwise>
64       </xsl:choose>
65      </xsl:attribute>
66     <!-- xlink:show='other' requires the exact modality to be -->
67     <!-- specified in non-xlink markup. The point is that the -->
68     <!-- element is already MathML ==> we can't add other     -->
69     <!-- markup without introducing another new namespace.    -->
70     <!-- So, for now no markup is used.                       -->
71      <xsl:attribute name="xlink:show">other</xsl:attribute>
72     </xsl:if>
73     <xsl:if test="$cnode/@helm:xref">
74      <xsl:attribute name="helm:xref">
75       <xsl:value-of select="$cnode/@helm:xref"/>
76      </xsl:attribute>
77     </xsl:if> 
78    </xsl:if>
79    <xsl:apply-templates mode="semantics"/>
80   </xsl:copy>
81 </xsl:template>
82
83 <!-- _top to refresh the whole frameset (avoids the matrioska effect ;-) -->
84 <!-- a[@href] doesn't match with every anchor elements!!!                -->
85 <xsl:template match="*[@href]">
86    <xsl:copy>
87     <xsl:copy-of select="@*"/> 
88     <xsl:choose>
89     <xsl:when test="starts-with(@href,&quot;nuprl:&quot;)">
90      <xsl:attribute name="href">
91       <xsl:call-template name="makeURL">
92        <xsl:with-param name="uri" select="@href"/>
93       </xsl:call-template>
94      </xsl:attribute>
95      <xsl:attribute name="target">cic</xsl:attribute>
96     </xsl:when>
97     <xsl:when test="starts-with(@href,&quot;theory:&quot;)">
98      <xsl:attribute name="href">
99       <xsl:call-template name="makeTheoryURL">
100        <xsl:with-param name="uri" select="@href"/>
101       </xsl:call-template>
102      </xsl:attribute>
103      <xsl:attribute name="target">theory</xsl:attribute>
104     </xsl:when>
105     <xsl:when test="starts-with(@href,&quot;#&quot;)">
106      <xsl:attribute name="href"><xsl:value-of  select="@href"/></xsl:attribute>
107      <xsl:if test="@target">
108       <xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
109      </xsl:if>
110     </xsl:when>
111     <xsl:otherwise>
112      <xsl:attribute name="href"><xsl:value-of  select="@href"/></xsl:attribute>
113      <xsl:attribute name="target">_blank</xsl:attribute>
114     </xsl:otherwise>
115     </xsl:choose>
116     <xsl:apply-templates/>
117    </xsl:copy>
118 </xsl:template>
119
120 <xsl:template match = "/|*">
121   <xsl:copy>
122    <xsl:copy-of select="@*"/>
123    <xsl:apply-templates/>
124   </xsl:copy>
125 </xsl:template>
126
127 </xsl:stylesheet>