Welcome to WebmasterWorld Guest from 54.196.243.192

Forum Moderators: httpwebwitch

Message Too Old, No Replies

google sitemap XML/XSL problem

     
10:38 pm on Aug 14, 2007 (gmt 0)

New User

5+ Year Member

joined:Aug 14, 2007
posts:2
votes: 0


Hi,

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

10:40 am on Aug 22, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts:1526
votes: 0


Welcome to WebmasterWorld!

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.

11:50 am on Aug 22, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 0


Yeah, it's a namespace issue.

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.

8:57 pm on Aug 23, 2007 (gmt 0)

New User

5+ Year Member

joined:Aug 14, 2007
posts:2
votes: 0


Thats brilliant. Thank you so much hunny :)

Take care,

Rachael

11:58 am on Aug 24, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 0


Glad it worked out for you, Sweetie. ;)
Good luck.