web/drupal/modules/xmlsitemap/gss/gss.xsl
branchdrupal
changeset 74 0ff3ba646492
equal deleted inserted replaced
73:fcf75e232c5b 74:0ff3ba646492
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 
       
     3 <xsl:stylesheet version="2.0"
       
     4                 xmlns:html="http://www.w3.org/TR/REC-html40"
       
     5                 xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
       
     6                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       
     7 
       
     8   <xsl:output method="html" version="1.0" encoding="utf-8" indent="yes"/>
       
     9 
       
    10   <!-- Root template -->
       
    11   <xsl:template match="/">
       
    12     <html>
       
    13       <head>
       
    14         <title>Site map file</title>
       
    15         <link href="/sites/all/modules/xmlsitemap/gss/gss.css" type="text/css" rel="stylesheet"/>
       
    16         <script src="/sites/all/modules/xmlsitemap/gss/gss.js"></script>
       
    17       </head>
       
    18 
       
    19       <!-- Store in $fileType if we are in a sitemap or in a siteindex -->
       
    20       <xsl:variable name="fileType">
       
    21         <xsl:choose>
       
    22       <xsl:when test="//sitemap:url">sitemap</xsl:when>
       
    23       <xsl:otherwise>siteindex</xsl:otherwise>
       
    24         </xsl:choose>
       
    25       </xsl:variable>
       
    26 
       
    27       <!-- Body -->
       
    28       <body onLoad="initXsl('table0','{$fileType}');">
       
    29 
       
    30         <!-- Text and table -->
       
    31         <h1 id="head1">Site map file:</h1>
       
    32           <xsl:choose>
       
    33         <xsl:when test="$fileType='sitemap'"><xsl:call-template name="sitemapTable"/></xsl:when>
       
    34         <xsl:otherwise><xsl:call-template name="siteindexTable"/></xsl:otherwise>
       
    35           </xsl:choose>
       
    36       </body>
       
    37     </html>
       
    38   </xsl:template>
       
    39 
       
    40   <!-- siteindexTable template -->
       
    41   <xsl:template name="siteindexTable">
       
    42     <h2>Number of site maps in this index: <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"></xsl:value-of></h2>
       
    43     <p class="sml">Click on the table headers to change sorting.</p>
       
    44     <table border="1" width="100%" class="data" id="table0">
       
    45       <tr class="header">
       
    46         <td>Site map URL</td>
       
    47         <td>Last modification date</td>
       
    48       </tr>
       
    49       <xsl:apply-templates select="sitemap:sitemapindex/sitemap:sitemap">
       
    50         <xsl:sort select="sitemap:lastmod" order="descending"/>
       
    51       </xsl:apply-templates>
       
    52     </table>
       
    53   </xsl:template>
       
    54 
       
    55   <!-- sitemapTable template -->
       
    56   <xsl:template name="sitemapTable">
       
    57     <h2>Number of URLs in this site map: <xsl:value-of select="count(sitemap:urlset/sitemap:url)"></xsl:value-of></h2>
       
    58     <p class="sml">Click on the table headers to change sorting.</p>
       
    59     <table border="1" width="100%" class="data" id="table0">
       
    60       <tr class="header">
       
    61         <td>Site map URL</td>
       
    62         <td>Last modification date</td>
       
    63         <td>Change freq.</td>
       
    64         <td>Priority</td>
       
    65       </tr>
       
    66       <xsl:apply-templates select="sitemap:urlset/sitemap:url">
       
    67         <xsl:sort select="sitemap:priority" order="descending"/>
       
    68       </xsl:apply-templates>
       
    69     </table>
       
    70   </xsl:template>
       
    71 
       
    72   <!-- sitemap:url template -->
       
    73   <xsl:template match="sitemap:url">
       
    74     <tr>
       
    75       <td>
       
    76         <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
       
    77         <a href="{$sitemapURL}" target="_blank" ref="nofollow"><xsl:value-of select="$sitemapURL"></xsl:value-of></a>
       
    78       </td>
       
    79       <td><xsl:value-of select="sitemap:lastmod"/></td>
       
    80       <td><xsl:value-of select="sitemap:changefreq"/></td>
       
    81       <td><xsl:value-of select="sitemap:priority"/></td>
       
    82     </tr>
       
    83   </xsl:template>
       
    84 
       
    85   <!-- sitemap:sitemap template -->
       
    86   <xsl:template match="sitemap:sitemap">
       
    87     <tr>
       
    88       <td>
       
    89         <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
       
    90         <a href="{$sitemapURL}"><xsl:value-of select="$sitemapURL"></xsl:value-of></a>
       
    91       </td>
       
    92       <td><xsl:value-of select="sitemap:lastmod"/></td>
       
    93     </tr>
       
    94   </xsl:template>
       
    95 
       
    96 </xsl:stylesheet>