-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathsitemap_style.xsl
51 lines (49 loc) · 2.42 KB
/
sitemap_style.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9">
<xsl:output method="html" encoding="UTF-8" indent="yes" />
<!-- The base URL is assumed to be the first URL in the sitemap. -->
<xsl:variable name="baseUrl" select="(sitemap:urlset/sitemap:url)[1]/sitemap:loc"/>
<!-- Remove http[s]:// -->
<xsl:variable name="baseUrlWithoutProtocol" select="substring-after($baseUrl, '://')"/>
<!-- Remove trailing slash -->
<xsl:variable name="clean_base_url" select="substring-before($baseUrlWithoutProtocol, '/')"/>
<xsl:template match="/sitemap:urlset">
<html>
<head>
<title>Sitemap • <xsl:value-of select="$clean_base_url"/></title>
<link rel="stylesheet" href="{$baseUrl}main.css"/>
<script src="{$baseUrl}js/sortTable.min.js" defer="defer"></script>
</head>
<body>
<div class="full-width">
<h1>Sitemap of <xsl:value-of select="$clean_base_url"/></h1>
<p>Number of URLs: <xsl:value-of select="count(sitemap:url)"/></p>
<table id="sitemapTable" class="sitemap-table" aria-label="URLs on the site and their last modification dates">
<thead>
<tr>
<th><span class="columntitle">URL</span></th>
<th><span class="columntitle">Last modification</span></th>
</tr>
</thead>
<tbody>
<xsl:for-each select="sitemap:url">
<tr>
<td>
<a href="{sitemap:loc}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="sitemap:lastmod"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>