Forum Moderators: open
I have done a simple sitemap.xml for my website:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.myexamplewebsite.co.uk/</loc>
</url>
</urlset>
and have an XSL stylesheet as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Site Map</h2>
<table border="0">
<xsl:for-each select="urlset/url">
<tr>
<td><xsl:value-of select="loc"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
When I try and display this in my browser it shows the heading "Site Map" but not the link data in the <loc> elements.
If I change the xml to remove "xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" from the <urlset> element it works fine.
I've also tried replacing my very basic xsl file with the google gss.xsl file and have the same problem.
Anybody got any ideas?
Thanks in advance, Rach
I apologize for not seeing this post earlier.
I'm not sure (yet) what the issue is. I'll look at it a bit more when I get time. I don't think it will be a big deal.
The for-each loop isn't resolving into anything. My first theory would be a namespace [rpbourret.com] problem. Namespaces tend to be the big blocker in XML.
This will fix it. You can simplify it if you want by making the sitemap namespace the default namespace:
The XML File (Untitled1.xml):
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Untitled2.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.myexamplewebsite.co.uk/</loc>
</url>
</urlset>
The XSLT File (Untitled2.xsl):
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xna="http://www.sitemaps.org/schemas/sitemap/0.9" exclude-result-prefixes="xna">
<xsl:output indent="yes" method="html" omit-xml-declaration="yes"/>
<xsl:template match="/">
<html>
<body>
<h2>Site Map</h2>
<table border="0">
<xsl:for-each select="xna:urlset/xna:url">
<tr>
<td><xsl:value-of select="xna:loc"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Again, apologies for not responding sooner. The email must have blown right past me. It's been busy in my day job.