]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/xslt/ls2html.xsl
"Bug" appearing under IE only fixed.
[helm.git] / helm / on-line / xslt / ls2html.xsl
1 <?xml version="1.0"?>
2
3
4 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
6 <xsl:output method="html" encoding="iso-8859-1"/>
7
8 <!-- uri must end with '/' -->
9 <xsl:param name="uri" select="''"/>
10 <xsl:param name="keys" select="''"/>
11 <xsl:param name="getterURL" select="''"/>
12 <xsl:param name="interfaceURL" select="''"/>
13 <xsl:param name="target" select="''"/>
14
15 <xsl:template name="chop">
16  <xsl:param name="uri" select="''"/>
17  <xsl:param name="prefix" select="''"/>
18  <xsl:variable name="newprefix" select="substring-before($uri,'/')"/>
19  <xsl:choose>
20   <xsl:when test="$newprefix = ''"><xsl:value-of select="$prefix"/></xsl:when>
21   <xsl:otherwise>
22    <xsl:call-template name="chop">
23     <xsl:with-param name="uri" select="substring-after($uri,'/')"/>
24     <xsl:with-param name="prefix" select="concat($prefix,$newprefix,'/')"/>
25    </xsl:call-template>
26   </xsl:otherwise>
27  </xsl:choose>
28 </xsl:template>
29
30 <xsl:variable name="uridotdot">
31  <xsl:call-template name="chop">
32   <xsl:with-param name="uri" select="substring($uri,1,string-length($uri)-1)"/>
33  </xsl:call-template>
34 </xsl:variable>
35
36 <xsl:template name="makeDir">
37  <xsl:param name="uri" select="''"/>
38  <xsl:param name="basename" select="''"/>
39  <xsl:param name="icon" select="''"/>
40  <xsl:param name="alt" select="''"/>
41  <tr>
42   <td>
43    <img border="0" src="{concat($interfaceURL,'/icons/',$icon)}" alt="[{$alt}]"/>
44   </td>
45   <td>
46 <!-- Substituted with next lines to avoid Mozilla 0.8 bug setting this.search
47     <a
48       onClick=
49        "top.{$target}uri='{$uri}';
50         refresh{$target}Header('{$interfaceURL}/html/library/header.html');
51         this.search='?keys={$keys}' +
52          '&amp;xmluri=' + escape('{$getterURL}ls?format=xml'+'&amp;baseuri={$uri}')+
53          '&amp;param.uri={$uri}' +
54          '&amp;param.keys={$keys}' +
55          '&amp;param.getterURL={$getterURL}' +
56          '&amp;param.target={$target}' +
57          '&amp;param.interfaceURL={$interfaceURL}';"
58       onMouseOver="window.status='{$uri}'; return true"
59       href="apply"
60    ><xsl:value-of select="$basename"/></a>
61 -->
62     <a
63       onClick=
64        "top.{$target}uri='{$uri}';
65         refresh{$target}Header('{$interfaceURL}/html/library/header.html');
66         var search='?keys={$keys}' +
67          '&amp;xmluri=' + escape('{$getterURL}ls?format=xml'+'&amp;baseuri={$uri}')+
68          '&amp;param.uri={$uri}' +
69          '&amp;param.keys={$keys}' +
70          '&amp;param.getterURL={$getterURL}' +
71          '&amp;param.target={$target}' +
72          '&amp;param.interfaceURL={$interfaceURL}';
73         var pathname = this.pathname;
74         // Next if to cope with IE idiosyncrasies
75         if (pathname.charAt(0) != '/')
76          pathname = '/' + pathname;
77         this.href=
78          this.protocol + '//' + this.host + pathname + search + this.hash;"
79       onMouseOver="window.status='{$uri}'; return true"
80       href="apply"
81    ><xsl:value-of select="$basename"/></a>
82   </td>
83  </tr>
84 </xsl:template>
85
86 <xsl:template match="/">
87  <html>
88   <head>
89    <title>Index of <xsl:value-of select="$uri"/></title>
90    <xsl:copy-of select="document(concat($interfaceURL,'/javascript/control.js_xml'))" />
91    <xsl:copy-of select="document(concat($interfaceURL,'/javascript/utils.js_xml'))" />
92   </head>
93   <body bgcolor="#ffffff" text="#000000">
94    <table>
95     <xsl:if test="$uridotdot != ''">
96      <xsl:call-template name="makeDir">
97       <xsl:with-param name="uri" select="$uridotdot"/>
98       <xsl:with-param name="basename" select="'Parent Directory'"/>
99       <xsl:with-param name="icon" select="'back.gif'"/>
100       <xsl:with-param name="alt" select="'Parent Directory'"/>
101      </xsl:call-template>
102     </xsl:if>
103     <xsl:apply-templates select="*"/>
104    </table>
105    <hr noshade="yes" align="left" width="80%"/>
106   </body>
107  </html>
108 </xsl:template>
109
110 <xsl:template match="section">
111  <xsl:variable name="diruri">
112   <xsl:value-of select="."/>
113  </xsl:variable>
114  <xsl:call-template name="makeDir">
115   <xsl:with-param name="uri" select="concat($uri,$diruri,'/')"/>
116   <xsl:with-param name="basename" select="$diruri"/>
117   <xsl:with-param name="icon" select="'folder.gif'"/>
118   <xsl:with-param name="alt" select="$uri"/>
119  </xsl:call-template>
120 </xsl:template>
121
122 <xsl:template match="object">
123  <xsl:variable name="name" select="@name"/>
124  <xsl:variable name="ann" select="ann/@value"/>
125  <xsl:variable name="types" select="types/@value"/>
126  <xsl:variable name="icon">
127   <xsl:choose>
128    <xsl:when test="$ann = 'YES'">text.gif</xsl:when>
129    <xsl:otherwise>generic.red.gif</xsl:otherwise>
130   </xsl:choose>
131  </xsl:variable>
132  <tr>
133   <td>
134    <img border="0" src="{concat($interfaceURL,'/icons/',$icon)}" alt="[{@name}]"/>
135   </td>
136   <td>
137    <a href="" target="{$target}"
138       onClick="this.href=makeURL('{$target}','{concat($uri,$name)}','{$ann}','{$types}')"
139       onMouseOver="window.status='{concat($uri,$name)}'; return true"
140    ><xsl:value-of select="$name"/></a>
141   </td>
142  </tr>
143 </xsl:template>
144
145 </xsl:stylesheet>