]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/xslt/ls2html.xsl
Many modifications to avoid JavaScript security rules of
[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         this.href=
74          this.protocol + '//' + this.host + this.pathname + search + this.hash;"
75       onMouseOver="window.status='{$uri}'; return true"
76       href="apply"
77    ><xsl:value-of select="$basename"/></a>
78   </td>
79  </tr>
80 </xsl:template>
81
82 <xsl:template match="/">
83  <html>
84   <head>
85    <title>Index of <xsl:value-of select="$uri"/></title>
86    <xsl:copy-of select="document(concat($interfaceURL,'/javascript/control.js_xml'))" />
87    <xsl:copy-of select="document(concat($interfaceURL,'/javascript/utils.js_xml'))" />
88   </head>
89   <body bgcolor="#ffffff" text="#000000">
90    <table>
91     <xsl:if test="$uridotdot != ''">
92      <xsl:call-template name="makeDir">
93       <xsl:with-param name="uri" select="$uridotdot"/>
94       <xsl:with-param name="basename" select="'Parent Directory'"/>
95       <xsl:with-param name="icon" select="'back.gif'"/>
96       <xsl:with-param name="alt" select="'Parent Directory'"/>
97      </xsl:call-template>
98     </xsl:if>
99     <xsl:apply-templates select="*"/>
100    </table>
101    <hr noshade="yes" align="left" width="80%"/>
102   </body>
103  </html>
104 </xsl:template>
105
106 <xsl:template match="section">
107  <xsl:variable name="diruri">
108   <xsl:value-of select="."/>
109  </xsl:variable>
110  <xsl:call-template name="makeDir">
111   <xsl:with-param name="uri" select="concat($uri,$diruri,'/')"/>
112   <xsl:with-param name="basename" select="$diruri"/>
113   <xsl:with-param name="icon" select="'folder.gif'"/>
114   <xsl:with-param name="alt" select="$uri"/>
115  </xsl:call-template>
116 </xsl:template>
117
118 <xsl:template match="object">
119  <xsl:variable name="name" select="@name"/>
120  <xsl:variable name="ann" select="ann/@value"/>
121  <xsl:variable name="types" select="types/@value"/>
122  <xsl:variable name="icon">
123   <xsl:choose>
124    <xsl:when test="$ann = 'YES'">text.gif</xsl:when>
125    <xsl:otherwise>generic.red.gif</xsl:otherwise>
126   </xsl:choose>
127  </xsl:variable>
128  <tr>
129   <td>
130    <img border="0" src="{concat($interfaceURL,'/icons/',$icon)}" alt="[{@name}]"/>
131   </td>
132   <td>
133    <a href="" target="{$target}"
134       onClick="this.href=makeURL('{$target}','{concat($uri,$name)}','{$ann}','{$types}')"
135       onMouseOver="window.status='{concat($uri,$name)}'; return true"
136    ><xsl:value-of select="$name"/></a>
137   </td>
138  </tr>
139 </xsl:template>
140
141 </xsl:stylesheet>