mlse
05-14-2007, 05:02 PM
Hi all, I have an issue concerning the formatting of sitemaps using XSLT in order to make them more human-readable.
Firstly, here's my test sitemap (small for ease of reading!):
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="sitemap.xsl" ?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>http://127.0.0.1/</loc>
<lastmod>2007-05-13</lastmod>
</url>
</urlset>
And here is my XSLT:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Sitemap for http://127.0.0.1/</h2>
<table>
<tr><td>Link</td><td>Lastmod</td></tr>
<xsl:for-each select="urlset/url">
<tr>
<td><xsl:value-of select="loc" /></td>
<td><xsl:value-of select="lastmod" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Check it out in a text editor - the for-each loop doesn't seem to result in any output to the browser. *HOWEVER* If the xmlns attribute of the urlset tag is removed in the target XML then the for-each loop works as you would expect!
Any ideas?
Firstly, here's my test sitemap (small for ease of reading!):
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="sitemap.xsl" ?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>http://127.0.0.1/</loc>
<lastmod>2007-05-13</lastmod>
</url>
</urlset>
And here is my XSLT:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Sitemap for http://127.0.0.1/</h2>
<table>
<tr><td>Link</td><td>Lastmod</td></tr>
<xsl:for-each select="urlset/url">
<tr>
<td><xsl:value-of select="loc" /></td>
<td><xsl:value-of select="lastmod" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Check it out in a text editor - the for-each loop doesn't seem to result in any output to the browser. *HOWEVER* If the xmlns attribute of the urlset tag is removed in the target XML then the for-each loop works as you would expect!
Any ideas?