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