Whilst XML sitemaps are great for Google, I always find they’re not so great for Humans like you and me. Their unfriendly appearance doesn’t make it immediately obvious that things are (or aren’t) happening as they’re supposed to.
That’s where XSL stylesheets come in. XSL stylesheets for XML sitemaps means that you can essentially render your XML sitemap as if it were a HTML page: easy to use and easy on the eye.
To create an ‘XML Stylesheet’ is really easy to, when you get right down to it. Simply create your template file and name it as you see fit – I’ve called our example file ‘template.xsl’ and link it in your XML sitemap like so:
<?xml-stylesheet href="/path/to/template.xsl" type="text/xsl"?>
Then we just have to deal with the code, the fun part. The CSS for your sitemaps easy – code as normal. The only area you need to pay attention to is the processing of the xml and how you code your template, as this needs to be done to the strict standard, as it is processed as such – any problems and you’ll get a parse error.
<table cellpadding="5">
<thead>
<tr>
<th width="90%">URL</th>
<th width="10%">Priority</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
I’ve included an example free template to play and modify to your hearts content:
Hooray for easy to read sitemaps! Thanks for reading today’s web design blog!

