]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/xslt/ls2html.xsl
0d551db35fe4cb04490eaf8677b5d057ce8a9e51
[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:import href="utils.xsl"/>
7
8 <xsl:output method="html" encoding="iso-8859-1"/>
9
10 <!-- uri must end with '/' -->
11 <xsl:param name="uri" select="''"/>
12 <xsl:param name="keys" select="''"/>
13 <xsl:param name="getterURL" select="''"/>
14 <xsl:param name="interfaceURL" select="''"/>
15 <xsl:param name="target" select="''"/>
16
17 <xsl:template name="chop">
18  <xsl:param name="uri" select="''"/>
19  <xsl:param name="prefix" select="''"/>
20  <xsl:variable name="newprefix" select="substring-before($uri,'/')"/>
21  <xsl:choose>
22   <xsl:when test="$newprefix = ''"><xsl:value-of select="$prefix"/></xsl:when>
23   <xsl:otherwise>
24    <xsl:call-template name="chop">
25     <xsl:with-param name="uri" select="substring-after($uri,'/')"/>
26     <xsl:with-param name="prefix" select="concat($prefix,$newprefix,'/')"/>
27    </xsl:call-template>
28   </xsl:otherwise>
29  </xsl:choose>
30 </xsl:template>
31
32 <xsl:variable name="uridotdot">
33  <xsl:call-template name="chop">
34   <xsl:with-param name="uri" select="substring($uri,1,string-length($uri)-1)"/>
35  </xsl:call-template>
36 </xsl:variable>
37
38 <xsl:template name="makeDir">
39  <xsl:param name="uri" select="''"/>
40  <xsl:param name="basename" select="''"/>
41  <xsl:param name="icon" select="''"/>
42  <xsl:param name="alt" select="''"/>
43  <tr>
44   <td>
45    <img border="0" src="{concat($interfaceURL,'/icons/',$icon)}" alt="[{$alt}]"/>
46   </td>
47   <td>
48     <xsl:variable name="quoteduri">
49      <xsl:call-template name="jsquote">
50       <xsl:with-param name="s" select="$uri"/>
51      </xsl:call-template>
52     </xsl:variable>
53     <a
54       onClick=
55        "top.{$target}uri='{$quoteduri}';
56         refresh{$target}Header('{$interfaceURL}/html/library/header.html');
57         var search='?keys={$keys}' +
58          '&amp;xmluri=' + escape('{$getterURL}ls?format=xml'+'&amp;baseuri={$quoteduri}')+
59          '&amp;param.uri={$quoteduri}' +
60          '&amp;param.keys={$keys}' +
61          '&amp;param.getterURL={$getterURL}' +
62          '&amp;param.target={$target}' +
63          '&amp;param.interfaceURL={$interfaceURL}';
64         var pathname = this.pathname;
65         if (pathname.charAt(0) != '/')
66          pathname = '/' + pathname;
67         this.href=
68          this.protocol + '//' + this.host + pathname + search + this.hash;"
69       onMouseOver="window.status='{$quoteduri}'; return true"
70       href="apply"
71    ><xsl:value-of select="$basename"/></a>
72   </td>
73  </tr>
74 </xsl:template>
75
76 <xsl:template match="/">
77  <html>
78   <head>
79    <title>Index of <xsl:value-of select="$uri"/></title>
80    <xsl:copy-of select="document(concat($interfaceURL,'/javascript/control.js_xml'))" />
81    <xsl:copy-of select="document(concat($interfaceURL,'/javascript/utils.js_xml'))" />
82   </head>
83   <body bgcolor="#ffffff" text="#000000">
84    <table>
85     <xsl:if test="$uridotdot != ''">
86      <xsl:call-template name="makeDir">
87       <xsl:with-param name="uri" select="$uridotdot"/>
88       <xsl:with-param name="basename" select="'Parent Directory'"/>
89       <xsl:with-param name="icon" select="'back.gif'"/>
90       <xsl:with-param name="alt" select="'Parent Directory'"/>
91      </xsl:call-template>
92     </xsl:if>
93     <xsl:apply-templates select="*"/>
94    </table>
95    <hr noshade="yes" align="left" width="80%"/>
96   </body>
97  </html>
98 </xsl:template>
99
100 <xsl:template match="section">
101  <xsl:variable name="diruri">
102   <xsl:value-of select="."/>
103  </xsl:variable>
104  <xsl:call-template name="makeDir">
105   <xsl:with-param name="uri" select="concat($uri,$diruri,'/')"/>
106   <xsl:with-param name="basename" select="$diruri"/>
107   <xsl:with-param name="icon" select="'folder.gif'"/>
108   <xsl:with-param name="alt" select="$uri"/>
109  </xsl:call-template>
110 </xsl:template>
111
112 <xsl:template match="object">
113  <xsl:variable name="name" select="@name"/>
114  <xsl:variable name="ann" select="ann/@value"/>
115  <xsl:variable name="types" select="types/@value"/>
116  <xsl:variable name="body" select="body/@value"/>
117  <xsl:variable name="proof_tree" select="proof_tree/@value"/>
118  <xsl:variable name="icon">
119   <xsl:choose>
120    <xsl:when test="$ann = 'YES'">text.gif</xsl:when>
121    <xsl:otherwise>generic.red.gif</xsl:otherwise>
122   </xsl:choose>
123  </xsl:variable>
124  <tr>
125   <td>
126    <img border="0" src="{concat($interfaceURL,'/icons/',$icon)}" alt="[{@name}]"/>
127   </td>
128   <td>
129    <xsl:variable name="quoteduri">
130     <xsl:call-template name="jsquote">
131      <xsl:with-param name="s" select="$uri"/>
132     </xsl:call-template>
133    </xsl:variable>
134    <xsl:variable name="quotedname">
135     <xsl:call-template name="jsquote">
136      <xsl:with-param name="s" select="$name"/>
137     </xsl:call-template>
138    </xsl:variable>
139    <xsl:variable name="quotedbodyname">
140     <xsl:call-template name="jsquote">
141      <xsl:with-param name="s" select="concat($name,'.body')"/>
142     </xsl:call-template>
143    </xsl:variable>
144    <xsl:variable name="quotedprooftreename">
145     <xsl:call-template name="jsquote">
146      <xsl:with-param name="s" select="concat($name,'.proof_tree')"/>
147     </xsl:call-template>
148    </xsl:variable>
149    <xsl:value-of select="$name"/>
150    <xsl:text> </xsl:text>
151    <a href="" target="{$target}"
152       onClick="this.href=makeURL('{$target}','{concat($quoteduri,$quotedname)}','{$ann}','{$types}')"
153       onMouseOver="window.status='{concat($quoteduri,$quotedname)}'; return true"
154    >
155     <xsl:choose>
156      <xsl:when test="not($body='NO')">Statement</xsl:when>
157      <xsl:otherwise>Definition</xsl:otherwise>
158     </xsl:choose>
159    </a>
160    <xsl:if test="not($body='NO')">
161     <xsl:text> </xsl:text>
162     <a href="" target="{$target}"
163        onClick="this.href=makeURL('{$target}','{concat($quoteduri,$quotedbodyname)}','{$ann}','{$types}')"
164        onMouseOver="window.status='{concat($quoteduri,$quotedname)}'; return true"
165     >Proof term</a>
166    </xsl:if>
167    <xsl:if test="not($proof_tree='NO')">
168     <xsl:text> </xsl:text>
169     <a href="" target="{$target}"
170        onClick="this.href=makeURL('{$target}','{concat($quoteduri,$quotedprooftreename)}','{$ann}','{$types}')"
171        onMouseOver="window.status='{concat($quoteduri,$quotedname)}'; return true"
172     >Proof tree</a>
173    </xsl:if>
174   </td>
175  </tr>
176 </xsl:template>
177
178 </xsl:stylesheet>