<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="2.0"
                xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


  <xsl:output method="html" version="4.0" encoding="ISO-8859-1" indent="yes" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

  <!-- Root template -->
  <xsl:template match="/">
    <html>
      <head>
        <title>Sitemap.xml</title>
		<style type="text/css">
		  <![CDATA[
			<!--
			body {
				font-family: Verdana, arial, sans-serif;
				font-size: 0.8em;
				height:100%;
			}
			body * {
				font-size: 100%;
			}
			dl {
				margin-top: 5px;
				border-top: 5px;
			}
			h1 {
				font-weight:bold;
				font-size:1.5em;
				margin-bottom:0;
				margin-top:1px; }

			h2 {
				font-weight:bold;
				font-size:1.2em;
				margin-bottom:0;
				color:#707070;
				margin-top:1px; }

			h3 {
				font-weight:bold;
				font-size:1.2em;
				margin-bottom:0;
				color:#000;
				margin-top:1px; }

			td, th {
				font-family: arial, sans-serif;
				font-size: 0.9em;
			}

			.header {
				font-weight: bold;
				font-size: 1.1em;
			}

			p.sml {
				font-size:0.8em;
				margin-top:0;
			}

			.data {
				border-collapse:collapse;
				border:1px solid #b0b0b0;
				margin-top:3px;
				width:100%;
				padding:5em;
			}

			.data td {
				border-bottom:1px solid #b0b0b0;
				text-align:left;
				padding:3px;
			}

			.sortup {
				background-position: right center;
				background-image: url(http://www.google.com/webmasters/sitemaps/images/sortup.gif);
				background-repeat: no-repeat;
				font-style:italic;
				white-space:pre; }

			.sortdown {
				background-position: right center;
				background-image: url(http://www.google.com/webmasters/sitemaps/images/sortdown.gif);
				background-repeat: no-repeat;
				font-style:italic;
				white-space:pre; }

			table.copyright {
				width:100%;
				border-top:1px solid #ddad08;
				margin-top:1em;
				text-align:center;
				padding-top:1em;
				vertical-align:top; }

			.copyright {
				color: #6F6F6F;
				font-size: 0.8em;
			}
			-->
		  ]]>
		</style>
      </head>

      <!-- Store in $fileType if we are in a sitemap or in a siteindex -->
      <xsl:variable name="fileType">
        <xsl:choose>
		  <xsl:when test="//sitemap:url">sitemap</xsl:when>
		  <xsl:otherwise>siteindex</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

      <!-- Body -->
      <body>
        <!-- Text and table -->
        <h1 id="head1">Evandro S. Stein - Evandro.Net</h1>
		<dl>
        <xsl:choose>
	      <xsl:when test="$fileType='sitemap'">
            <h1>Site Index</h1>
		    <xsl:call-template name="sitemapTable"/>
		  </xsl:when>
	      <xsl:otherwise>
            <h1>SiteMap Index</h1>
		    <xsl:call-template name="siteindexTable"/>
		  </xsl:otherwise>
  	      </xsl:choose>
		</dl>
        <!-- Copyright notice -->
        <br/>
        <dl>
          <dd>Sitemaps Style Sheet: <a href="http://evandro.net/webdesign/sitemap.xsl.html">sitemap.xsl</a> - <a href="http://www.sitemaps.org/">Sitemaps.org</a></dd>
		</dl>
      </body>
    </html>
  </xsl:template>

  <!-- siteindexTable template -->
  <xsl:template name="siteindexTable">
    <h2>Number of sitemaps in this Google sitemap index: <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"></xsl:value-of></h2>
    <h3>Sitemap URL</h3>
    <dl>Last modification date
      <xsl:apply-templates select="sitemap:sitemapindex/sitemap:sitemap">
        <xsl:sort select="sitemap:lastmod" order="descending"/>
      </xsl:apply-templates>
    </dl>
  </xsl:template>

  <!-- sitemapTable template -->
  <xsl:template name="sitemapTable">
    <h2>Number of URLs in this Google Sitemap: <xsl:value-of select="count(sitemap:urlset/sitemap:url)"></xsl:value-of></h2>
	  <xsl:apply-templates select="sitemap:urlset/sitemap:url">
	    <xsl:sort select="sitemap:priority" order="descending"/>
	  </xsl:apply-templates>
  </xsl:template>

  <!-- sitemap:url template -->
  <xsl:template match="sitemap:url">
        <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
        <dl><a href="{$sitemapURL}" target="_blank"><xsl:value-of select="$sitemapURL"></xsl:value-of></a></dl>
  </xsl:template>

  <!-- sitemap:sitemap template -->
  <xsl:template match="sitemap:sitemap">
        <xsl:variable name="sitemapURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
        <dl><a href="{$sitemapURL}"><xsl:value-of select="$sitemapURL"></xsl:value-of></a></dl>
  </xsl:template>

</xsl:stylesheet>
