xmlsitemap.xsl 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Google Sitmaps Stylesheets (GSStylesheets)
  3. Project Home: http://sourceforge.net/projects/gstoolbox
  4. Copyright (c) 2005 Baccou Bonneville SARL (http://www.baccoubonneville.com)
  5. License http://www.gnu.org/copyleft/lesser.html GNU/LGPL -->
  6. <xsl:stylesheet version="2.0"
  7. xmlns:html="http://www.w3.org/TR/REC-html40"
  8. xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  10. <xsl:output method="html" version="1.0" encoding="utf-8" indent="yes"/>
  11. <!-- Root template -->
  12. <xsl:template match="/">
  13. <html>
  14. <head>
  15. <title>Sitemap file</title>
  16. <script type="text/javascript" src="[jquery]"></script>
  17. <script type="text/javascript" src="[jquery-tablesort]"></script>
  18. <script type="text/javascript" src="[xsl-js]"></script>
  19. <link href="[xsl-css]" type="text/css" rel="stylesheet"/>
  20. </head>
  21. <!-- Store in $fileType if we are in a sitemap or in a siteindex -->
  22. <xsl:variable name="fileType">
  23. <xsl:choose>
  24. <xsl:when test="//sitemap:url">sitemap</xsl:when>
  25. <xsl:otherwise>siteindex</xsl:otherwise>
  26. </xsl:choose>
  27. </xsl:variable>
  28. <body>
  29. <h1>Sitemap file</h1>
  30. <xsl:choose>
  31. <xsl:when test="$fileType='sitemap'"><xsl:call-template name="sitemapTable"/></xsl:when>
  32. <xsl:otherwise><xsl:call-template name="siteindexTable"/></xsl:otherwise>
  33. </xsl:choose>
  34. <div id="footer">
  35. <p>Generated by the <a href="http://drupal.org/project/xmlsitemap">Drupal XML sitemap module</a>.</p>
  36. </div>
  37. </body>
  38. </html>
  39. </xsl:template>
  40. <!-- siteindexTable template -->
  41. <xsl:template name="siteindexTable">
  42. <div id="information">
  43. <p>Number of sitemaps in this index: <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"></xsl:value-of></p>
  44. </div>
  45. <table class="tablesorter siteindex">
  46. <thead>
  47. <tr>
  48. <td>Sitemap URL</td>
  49. <td>Last modification date</td>
  50. </tr>
  51. </thead>
  52. <tbody>
  53. <xsl:apply-templates select="sitemap:sitemapindex/sitemap:sitemap">
  54. <xsl:sort select="sitemap:lastmod" order="descending"/>
  55. </xsl:apply-templates>
  56. </tbody>
  57. </table>
  58. </xsl:template>
  59. <!-- sitemapTable template -->
  60. <xsl:template name="sitemapTable">
  61. <div id="information">
  62. <p>Number of URLs in this sitemap: <xsl:value-of select="count(sitemap:urlset/sitemap:url)"></xsl:value-of></p>
  63. </div>
  64. <table class="tablesorter sitemap">
  65. <thead>
  66. <tr>
  67. <th>URL location</th>
  68. <th>Last modification date</th>
  69. <th>Change frequency</th>
  70. <th>Priority</th>
  71. </tr>
  72. </thead>
  73. <tbody>
  74. <xsl:apply-templates select="sitemap:urlset/sitemap:url">
  75. <xsl:sort select="sitemap:priority" order="descending"/>
  76. </xsl:apply-templates>
  77. </tbody>
  78. </table>
  79. </xsl:template>
  80. <!-- sitemap:url template -->
  81. <xsl:template match="sitemap:url">
  82. <tr>
  83. <td>
  84. <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
  85. <a href="{$sitemapURL}" ref="nofollow"><xsl:value-of select="$sitemapURL"></xsl:value-of></a>
  86. </td>
  87. <td><xsl:value-of select="sitemap:lastmod"/></td>
  88. <td><xsl:value-of select="sitemap:changefreq"/></td>
  89. <td>
  90. <xsl:choose>
  91. <!-- If priority is not defined, show the default value of 0.5 -->
  92. <xsl:when test="sitemap:priority">
  93. <xsl:value-of select="sitemap:priority"/>
  94. </xsl:when>
  95. <xsl:otherwise>0.5</xsl:otherwise>
  96. </xsl:choose>
  97. </td>
  98. </tr>
  99. </xsl:template>
  100. <!-- sitemap:sitemap template -->
  101. <xsl:template match="sitemap:sitemap">
  102. <tr>
  103. <td>
  104. <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
  105. <a href="{$sitemapURL}"><xsl:value-of select="$sitemapURL"></xsl:value-of></a>
  106. </td>
  107. <td><xsl:value-of select="sitemap:lastmod"/></td>
  108. </tr>
  109. </xsl:template>
  110. </xsl:stylesheet>