Hello...I've been trying to figure out this problem for most of the week - it's my second attempt at any XML and my first at XSLT so I haven't got a complete grasp of what I'm doing yet. Any help will be muchly appreciated. :)

The problem is, the code below validates and works in IE7 (obviously with their pre-set stylesheet). In IE6 the text describing the feed from the XSL file displays, but none of the actual news items between the <entry> tags of the XML file do i.e. the whole point of having the feed!

There is a way it DOES work in IE6 and Firefox 1.5, but doesn't work in IE7 (I'll explain below the code).

news-test.asp (generated with ASP and with company info removed):

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="news-feed.xsl"?>
<feed xmlns:atom="http://www.w3.org/2005/Atom">

  <title>-- Latest News</title>
  <updated>2008-01-11T11:00:00+00:00</updated>
  <id>tag:www.--.co.uk,2007-12-03:/news.asp</id>
  <link rel="alternate" href="http://www.--.co.uk/news.asp"/>
  <link rel="self" href="http://www.--.co.uk/news-feed.asp"/>
  <rights>--</rights>
  <logo>http://www.--.co.uk/feed/logo.gif</logo>

  <author>
  	<name>--</name>
	<uri>http://www.--.co.uk</uri>
  </author>
		 
  <entry>
    <title>Title</title>
    <link rel="alternate" href="http://www.--.co.uk/news_story.asp?id=2197"/>
    <content type="html"><![CDATA[Blah blah blah...]]></content>
    <id>tag:www.--.co.uk,2007-12-03:/news_story.asp?id=2197</id>
    <updated>2008-01-11T11:00:00+00:00</updated>
  </entry>
 
  <entry>
    <title>Title</title>
    <link rel="alternate" href="http://www.--.co.uk/news_story.asp?id=2196"/>
    <content type="html"><![CDATA[Blah blah blah...]]></content>
    <id>tag:www.--.co.uk,2007-12-03:/news_story.asp?id=2196</id>
    <updated>2008-01-10T16:50:00+00:00</updated>
  </entry>
 
  <entry>
    <title>Title</title>
    <link rel="alternate" href="http://www.--.co.uk/news_story.asp?id=2195"/>
    <content type="html"><![CDATA[Blah blah blah...]]></content>
    <id>tag:www.--.co.uk,2007-12-03:/news_story.asp?id=2195</id>
    <updated>2008-01-10T14:49:00+00:00</updated>
  </entry>
		
</feed>

news-feed.xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>

<xsl:template match="/">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<body style="font-family: Arial,helvetica,sans-serif; background-color:#ffffff">
	
	<h2 style="color: #ff3300;">PPP/PFI News</h2>
	
		<div style="font-size: 0.8em; margin: 0.5em 0em 1em 0em;">
			This page is for the <a href="http://www.--.co.uk">www.--.co.uk</a> News syndication feed. Feeds allow you to stay up to date with the latest news and features by adding the feed address to a news aggregator program, or to your own website.
			<br /><br />There are various ways to subscribe, including:
			<ul><li>Dragging the orange feed button (<a href="news-feed.asp"><img src="feed/feed.gif" border="0" width="16" height="16" hspace="1" style="vertical-align: middle;" /></a>) or URL of the feed into your News Reader software</li>
			<li>Cutting and pasting the URL of the feed into your News Reader</li>
			</ul>
			The latest content for this feed can be viewed below.
		</div>
	
	<xsl:for-each select="feed/entry">
	
		<div style="color:#000000; padding: 0.3em;">
	  
			<h3 style="font-size: 1em; padding: 0em; margin: 0em;">
			<a><xsl:attribute name="href"><xsl:value-of select="link/@href"/></xsl:attribute><xsl:value-of select="title" disable-output-escaping="yes"/></a>
			</h3>
			
		</div>
		
		<div style="margin-left: 0.5em; margin-bottom: 0.9em; font-size:0.8em;">
			<xsl:value-of select="description"/>
			
			<span><xsl:value-of select="content"/></span>
		</div>
	
	</xsl:for-each>
	</body>
	</html>
</xsl:template>
</xsl:stylesheet>

It works in IE6 and Firefox but DOESN'T display in IE7 ("internet explorer does not support this feed format") if I change the namespace declaration from <feed xmlns="http://www.w3.org/2005/Atom"> to <feed xmlns:atom="http://www.w3.org/2005/Atom"> or infact if I add any bit of random text like :aaaaaaaargh there

Thanks for looking.

Solved! And just incase this might help anyone in future, here is the solution from Jeni and her XML pages at www.jenitennison.com

The use of the default namespace in the Atom feed means that the <feed>, <entry> etc. elements are in the Atom namespace.

In your stylesheet, you’re doing:

<xsl:for-each select="feed/entry">
...
</xsl:for-each>
When you select elements in XSLT, if you don’t give a prefix for the element then the processor will only look for elements in no namespace. So in this case you’re selecting <feed> elements in no namespace and their <entry> element children (in no namespace again).

You already have the Atom namespace declared in the stylesheet with the prefix atom. The solution is simply to use that prefix whenever you refer to an Atom element:

<xsl:for-each select="atom:feed/atom:entry">
...
</xsl:for-each>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.