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