source: spip-zone/_plugins_/sitemapxsl/xmlsitemap.xsl.html

Last change on this file was 84568, checked in by real3t@…, 6 years ago

Un plugin pour avoir une SiteMap lisible par un être humain (transformation du .xml par une feuille .xsl)

Mise en plugin SPIP de https://www.drupal.org/project/xmlsitemap

File size: 5.0 KB
Line 
1#HTTP_HEADER{Content-Type: text/xml; charset=utf-8}
2<?xml version="1.0" encoding="UTF-8"?>
3
4<!-- Copyright (c) 2010  Dave Reid <http://drupal.org/user/53892>
5
6     This file is free software: you may copy, redistribute and/or modify it
7     under the terms of the GNU General Public License as published by the
8     Free Software Foundation, either version 2 of the License, or (at your
9     option) any later version.
10
11     This file is distributed in the hope that it will be useful, but
12     WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14     General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19     This file incorporates work covered by the following copyright and
20     permission notice:
21
22     Google Sitmaps Stylesheets (GSStylesheets)
23     Project Home: http://sourceforge.net/projects/gstoolbox
24     Copyright (c) 2005 Baccou Bonneville SARL (http://www.baccoubonneville.com)
25     License http://www.gnu.org/copyleft/lesser.html GNU/LGPL -->
26
27<xsl:stylesheet version="2.0"
28    xmlns:html="http://www.w3.org/TR/REC-html40"
29    xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
30    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
31  <xsl:output method="html" version="1.0" encoding="utf-8" indent="yes"/>
32  <!-- Root template -->
33  <xsl:template match="/">
34    <html>
35      <head>
36        <title>Sitemap file</title>
37        <script type="text/javascript" src="#CHEMIN{xsl/jquery-1.8.3.js}"></script>
38        <script type="text/javascript" src="#CHEMIN{xsl/jquery.tablesorter.min.js}"></script>
39        <script type="text/javascript" src="#CHEMIN{xsl/xmlsitemap.xsl.js}"></script>
40        <link href="#CHEMIN{xsl/xmlsitemap.xsl.css}" type="text/css" rel="stylesheet"/>
41      </head>
42
43      <!-- Store in $fileType if we are in a sitemap or in a siteindex -->
44      <xsl:variable name="fileType">
45        <xsl:choose>
46          <xsl:when test="//sitemap:url">sitemap</xsl:when>
47          <xsl:otherwise>siteindex</xsl:otherwise>
48        </xsl:choose>
49      </xsl:variable>
50
51      <body>
52        <h1>Sitemap file</h1>
53        <xsl:choose>
54          <xsl:when test="$fileType='sitemap'"><xsl:call-template name="sitemapTable"/></xsl:when>
55          <xsl:otherwise><xsl:call-template name="siteindexTable"/></xsl:otherwise>
56        </xsl:choose>
57
58        <div id="footer">
59          <p>Produit par <a href="#TODO">Plugin SPIP SitemapXSL</a>.</p>
60        </div>
61      </body>
62    </html>
63  </xsl:template>
64
65  <!-- siteindexTable template -->
66  <xsl:template name="siteindexTable">
67    <div id="information">
68      <p>Number of sitemaps in this index: <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"></xsl:value-of></p>
69    </div>
70    <table class="tablesorter siteindex">
71      <thead>
72        <tr>
73          <th>Sitemap URL</th>
74          <th>Last modification date</th>
75        </tr>
76      </thead>
77      <tbody>
78        <xsl:apply-templates select="sitemap:sitemapindex/sitemap:sitemap">
79          <xsl:sort select="sitemap:lastmod" order="descending"/>
80        </xsl:apply-templates>
81      </tbody>
82    </table>
83  </xsl:template>
84
85  <!-- sitemapTable template -->
86  <xsl:template name="sitemapTable">
87    <div id="information">
88      <p>Number of URLs in this sitemap: <xsl:value-of select="count(sitemap:urlset/sitemap:url)"></xsl:value-of></p>
89    </div>
90    <table class="tablesorter sitemap">
91      <thead>
92        <tr>
93          <th>URL location</th>
94          <th>Last modification date</th>
95          <th>Change frequency</th>
96          <th>Priority</th>
97        </tr>
98      </thead>
99      <tbody>
100        <xsl:apply-templates select="sitemap:urlset/sitemap:url">
101          <xsl:sort select="sitemap:priority" order="descending"/>
102        </xsl:apply-templates>
103      </tbody>
104    </table>
105  </xsl:template>
106
107  <!-- sitemap:url template -->
108  <xsl:template match="sitemap:url">
109    <tr>
110      <td>
111        <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
112        <a href="{$sitemapURL}" ref="nofollow"><xsl:value-of select="$sitemapURL"></xsl:value-of></a>
113      </td>
114      <td><xsl:value-of select="sitemap:lastmod"/></td>
115      <td><xsl:value-of select="sitemap:changefreq"/></td>
116      <td>
117        <xsl:choose>
118          <!-- If priority is not defined, show the default value of 0.5 -->
119          <xsl:when test="sitemap:priority">
120            <xsl:value-of select="sitemap:priority"/>
121          </xsl:when>
122          <xsl:otherwise>0.5</xsl:otherwise>
123        </xsl:choose>
124      </td>
125    </tr>
126  </xsl:template>
127
128  <!-- sitemap:sitemap template -->
129  <xsl:template match="sitemap:sitemap">
130    <tr>
131      <td>
132        <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
133        <a href="{$sitemapURL}"><xsl:value-of select="$sitemapURL"></xsl:value-of></a>
134      </td>
135      <td><xsl:value-of select="sitemap:lastmod"/></td>
136    </tr>
137  </xsl:template>
138</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.