sitemap.xsl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="2.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
  5. xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
  6. xmlns:html="http://www.w3.org/TR/REC-html40">
  7. <xsl:output version="1.0" method="html" encoding="UTF-8" />
  8. <xsl:template match="/">
  9. <html xmlns="http://www.w3.org/1999/xhtml">
  10. <head>
  11. <title>Sitemap XML</title>
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  13. <style type="text/css">
  14. html,
  15. body {
  16. color: #333;
  17. font-family: Arial, sans-serif;
  18. font-size: 14px;
  19. line-height: 1.4;
  20. }
  21. a {
  22. color: #000;
  23. text-decoration: none;
  24. }
  25. a:hover {
  26. text-decoration: underline;
  27. }
  28. .wrapper {
  29. margin: 20px auto;
  30. width: 1240px;
  31. }
  32. .header {
  33. font-size: 32px;
  34. font-weight: normal;
  35. }
  36. .info {
  37. margin: 25px 0;
  38. }
  39. .list {
  40. width: 100%;
  41. }
  42. .list,
  43. .list td,
  44. .list th {
  45. border: none;
  46. }
  47. .list td,
  48. .list th {
  49. padding: 5px;
  50. }
  51. .list thead th {
  52. background: #eee;
  53. }
  54. .list tr:nth-child(even) td {
  55. background-color: #f0f0f0;
  56. }
  57. </style>
  58. </head>
  59. <body>
  60. <div class="wrapper">
  61. <h1 class="header">Sitemap XML</h1>
  62. <div class="info">This sitemap contains <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs.</div>
  63. <table class="list" border="none" cellspacing="0" cellpadding="3">
  64. <thead>
  65. <tr>
  66. <th width="70%">URL</th>
  67. <th width="10%">Images</th>
  68. <th width="20%">Last Modified</th>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. <xsl:for-each select="sitemap:urlset/sitemap:url">
  73. <tr>
  74. <td>
  75. <xsl:variable name="url"><xsl:value-of select="sitemap:loc"/></xsl:variable>
  76. <a href="{$url}"><xsl:value-of select="sitemap:loc"/></a>
  77. </td>
  78. <td style="text-align: center;">
  79. <xsl:value-of select="count(image:image)"/>
  80. </td>
  81. <td style="text-align: center; font-family: monospace;">
  82. <xsl:value-of select="concat( substring( sitemap:lastmod, 0, 11), concat(' ', substring( sitemap:lastmod, 12, 14 ) ) )"/>
  83. </td>
  84. </tr>
  85. </xsl:for-each>
  86. </tbody>
  87. </table>
  88. </div>
  89. </body>
  90. </html>
  91. </xsl:template>
  92. </xsl:stylesheet>