-
Notifications
You must be signed in to change notification settings - Fork 692
/
Copy pathxmlindex-html.xsl
146 lines (140 loc) · 3.52 KB
/
xmlindex-html.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/TR/html4/"
xmlns="http://www.w3.org/TR/html4/"
exclude-result-prefixes="html">
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Strict//EN"
indent="yes" doctype-system="http://www.w3.org/TR/html4/strict.dtd"
encoding="UTF-8" />
<xsl:template name="format-date">
<xsl:param name="date" />
<xsl:value-of select="substring-before($date, 'T')" />
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after($date, 'T')" />
</xsl:template>
<xsl:template match="index">
<html>
<head>
<xsl:choose>
<xsl:when test="$stylesheet">
<link rel="stylesheet" type="text/css" media="all" href="{$stylesheet}" />
</xsl:when>
<xsl:otherwise>
<style type="text/css">
html {
color: #000000;
background-color: #fefefe;
font-family: sans-serif;
}
h1 {
font-size: 1.5em;
font-weight: bold;
margin: .67em 0;
}
th {
text-align: left;
}
td {
font-family: mono;
}
td, th {
padding: 0 1em;
}
td.size {
text-align: right;
}
:link, :visited {
text-decoration: none;
}
:link {
color: #000099;
}
:visited {
color: #6600cc;
}
:link:hover,
:visited:hover {
text-decoration: underline;
}
:link:focus,
:visited:focus {
text-decoration: underline;
}
:link:active,
:visited:active {
text-decoration: underline;
}
</style>
</xsl:otherwise>
</xsl:choose>
<title>Index of <xsl:value-of select="@path" /></title>
</head>
<body>
<h1>Index of <xsl:value-of select="@path" /></h1>
<table>
<tr>
<th class="name">Name</th>
<th class="mtime">Last Modified</th>
<th class="size">Size</th>
</tr>
<tr>
<td class="name" colspan="3"><a href=".." title="Parent">Parent directory</a></td>
</tr>
<xsl:apply-templates select="directory" />
<xsl:apply-templates select="file" />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="directory">
<tr class="directory">
<td class="name">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="." />
<xsl:text>/</xsl:text>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="." />
<xsl:text>/</xsl:text>
</xsl:attribute>
<xsl:value-of select="." />
<xsl:text>/</xsl:text>
</xsl:element>
</td>
<td class="mtime">
<xsl:call-template name="format-date">
<xsl:with-param name="date" select="@mtime" />
</xsl:call-template>
</td>
<td class="size">
<xsl:value-of select="@size" />
</td>
</tr>
</xsl:template>
<xsl:template match="file">
<tr class="file">
<td class="name">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:value-of select="." />
</xsl:element>
</td>
<td class="mtime">
<xsl:call-template name="format-date">
<xsl:with-param name="date" select="@mtime" />
</xsl:call-template>
</td>
<td class="size">
<xsl:value-of select="@size" />
</td>
</tr>
</xsl:template>
</xsl:stylesheet>