943,954 Members | Top Members by Rank

Jan 11th, 2008
0

XML Atom feed IE6 and Firefox vs. IE7 problem

Expand Post »
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):
RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <?xml-stylesheet type="text/xsl" href="news-feed.xsl"?>
  3. <feed xmlns:atom="http://www.w3.org/2005/Atom">
  4.  
  5. <title>-- Latest News</title>
  6. <updated>2008-01-11T11:00:00+00:00</updated>
  7. <id>tag:www.--.co.uk,2007-12-03:/news.asp</id>
  8. <link rel="alternate" href="http://www.--.co.uk/news.asp"/>
  9. <link rel="self" href="http://www.--.co.uk/news-feed.asp"/>
  10. <rights>--</rights>
  11. <logo>http://www.--.co.uk/feed/logo.gif</logo>
  12.  
  13. <author>
  14. <name>--</name>
  15. <uri>http://www.--.co.uk</uri>
  16. </author>
  17.  
  18. <entry>
  19. <title>Title</title>
  20. <link rel="alternate" href="http://www.--.co.uk/news_story.asp?id=2197"/>
  21. <content type="html"><![CDATA[Blah blah blah...]]></content>
  22. <id>tag:www.--.co.uk,2007-12-03:/news_story.asp?id=2197</id>
  23. <updated>2008-01-11T11:00:00+00:00</updated>
  24. </entry>
  25.  
  26. <entry>
  27. <title>Title</title>
  28. <link rel="alternate" href="http://www.--.co.uk/news_story.asp?id=2196"/>
  29. <content type="html"><![CDATA[Blah blah blah...]]></content>
  30. <id>tag:www.--.co.uk,2007-12-03:/news_story.asp?id=2196</id>
  31. <updated>2008-01-10T16:50:00+00:00</updated>
  32. </entry>
  33.  
  34. <entry>
  35. <title>Title</title>
  36. <link rel="alternate" href="http://www.--.co.uk/news_story.asp?id=2195"/>
  37. <content type="html"><![CDATA[Blah blah blah...]]></content>
  38. <id>tag:www.--.co.uk,2007-12-03:/news_story.asp?id=2195</id>
  39. <updated>2008-01-10T14:49:00+00:00</updated>
  40. </entry>
  41.  
  42. </feed>

news-feed.xsl:
RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
  3. <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
  4.  
  5. <xsl:template match="/">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <body style="font-family: Arial,helvetica,sans-serif; background-color:#ffffff">
  8.  
  9. <h2 style="color: #ff3300;">PPP/PFI News</h2>
  10.  
  11. <div style="font-size: 0.8em; margin: 0.5em 0em 1em 0em;">
  12. 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.
  13. <br /><br />There are various ways to subscribe, including:
  14. <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>
  15. <li>Cutting and pasting the URL of the feed into your News Reader</li>
  16. </ul>
  17. The latest content for this feed can be viewed below.
  18. </div>
  19.  
  20. <xsl:for-each select="feed/entry">
  21.  
  22. <div style="color:#000000; padding: 0.3em;">
  23.  
  24. <h3 style="font-size: 1em; padding: 0em; margin: 0em;">
  25. <a><xsl:attribute name="href"><xsl:value-of select="link/@href"/></xsl:attribute><xsl:value-of select="title" disable-output-escaping="yes"/></a>
  26. </h3>
  27.  
  28. </div>
  29.  
  30. <div style="margin-left: 0.5em; margin-bottom: 0.9em; font-size:0.8em;">
  31. <xsl:value-of select="description"/>
  32.  
  33. <span><xsl:value-of select="content"/></span>
  34. </div>
  35.  
  36. </xsl:for-each>
  37. </body>
  38. </html>
  39. </xsl:template>
  40. </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.
Reputation Points: 12
Solved Threads: 2
Junior Poster in Training
TheAlex is offline Offline
66 posts
since Feb 2005
Jan 24th, 2008
0

Re: XML Atom feed IE6 and Firefox vs. IE7 problem

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

Quote ...
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>
Reputation Points: 12
Solved Threads: 2
Junior Poster in Training
TheAlex is offline Offline
66 posts
since Feb 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in RSS, Web Services and SOAP Forum Timeline: Adding Attributes to all XML Nodes
Next Thread in RSS, Web Services and SOAP Forum Timeline: MSSoap SDK 3.0 - Unable to read a SOAP file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC