0

我正在尝试使用我创建的 RSS 提要。它有两个链接的 css 和 xls 文档,一个 css 作为故障保护,以防 xsl 不起作用,另一个 css 用于 xls 格式化提要。网址在这里:

http://rockthepatch.com/rss/current-events.xml

RSS 提要如下所示:

<?xml version="1.0" encoding="iso-8859-1"?>

<?xml-stylesheet type="text/css" href="http://www.rockthepatch.com/css/rss.css"?>
<?xml-stylesheet type="text/xsl" href="http://www.rockthepatch.com/rss/current-events.xsl"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <language>en-us</language>
    <title>Upcoming Rock the Patch! Events</title>
    <link>http://www.rockthepatch.com/rss/current-events.xml</link>
    <description>See what's coming up below:</description>
    <atom:link href="http://www.rockThePatch.com/rss/current-events.xml" rel="self"     type="application/rss+xml" />

    <item>
      <title>Thursday's Open Mic at Ole Simms</title>
      <link>https://www.facebook.com/olesimrells</link>
      <description>Join Patches at open mic night at Terre Haute's Ole Simmerls Bar around 9 P.M. every Thursday.</description>
      <guid>http://www.indstate.edu/mpa/sarah/rockThePatch/rss/item0001</guid>
      <pubDate>Mon, 10 Oct 2011 09:15:00 EST</pubDate>
      <author>sklinefelter89@gmail.com (Patches)</author>
    </item>
    <item>
      <title>Fall Break is Here!</title>
      <link>http://www.indstate.edu/academicaffairs/calendar.htm</link>
      <description>School and work will not happen on Friday due to FALL BREAK!!!    </description>
      <guid>http://www.indstate.edu/mpa/sarah/rockThePatch/rss/item0002</guid>
      <pubDate>Fri, 07 Oct 2011 02:23:00 EST</pubDate>
      <author>sklinefelter89@gmail.com (Patches)</author>
    </item>
  </channel>
</rss>

xsl 看起来像这样:

<?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>
      <head>
          <link rel="stylesheet" href="http://www.rockthepatch.com/css/xsl.css"     type="text/css"/>
      </head>
      <body>
        <h2>Upcoming Rock the Patch! Events</h2>
        <table border="1px">
          <tr>
            <th>Name of Event</th>
            <th>Description</th>
            <th>Date Posted</th>
            <th>Author</th>
         </tr>
      <xsl:for-each select="rss/channel/item">
        <tr>
              <td>
            <xsl:value-of select="title"/>
          </td>
          <!-- <td>
            <a href="&lt;xsl:value-of select='link'/&gt;" title="Link">
              <xsl:value-of select="link"/>
            </a>
          </td> -->
          <td>
            <xsl:value-of select="description"/>
          </td>
          <td>
            <xsl:value-of select="pubDate"/>
          </td>
          <td>
                <a href="mailto:sklinefelter89@gmail.com" title="sklinefelter89@gmail.com">
                  <xsl:value-of select="author"/>
                </a>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>

我不想下载文件,但每次我点击链接时,它都会下载而不是在任何浏览器中显示......有人能指出我做错了什么吗?

4

1 回答 1

0

我从您的 URL 检查了 HTTP 标头。您发送的内容类型为application/xhtml+xml. 您应该将其更改为application/rss+xml. 那应该可以解决问题。

我将您的 xml 文件放在冷融合服务器上以重现问题。然后将扩展名更改为 cfm,添加<cfcontent type = "application/rss+xml">,它可以按您的意愿工作(无需下载)。

于 2012-08-31T16:10:56.903 回答