homepage Welcome to WebmasterWorld Guest from 54.161.197.188
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
google sitemap XML/XSL problem
RachP




msg:3422266
 10:38 pm on Aug 14, 2007 (gmt 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

 

cmarshall




msg:3428718
 10:40 am on Aug 22, 2007 (gmt 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.

cmarshall




msg:3428768
 11:50 am on Aug 22, 2007 (gmt 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.

RachP




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

Thats brilliant. Thank you so much hunny :)

Take care,

Rachael

cmarshall




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved