Skip to main content
Participant
June 28, 2010
Question

XSL Transform Problem

  • June 28, 2010
  • 1 reply
  • 718 views

I'm having trouble with an XSL Fragment on a page on my website. I am just trying to feed the most recent five entries from my blog to a page on the website and present them in descending order. The web page is at the following link:

http://localhost/sites/newclues/blog.asp

The asp code is as follows:

    <%
var mm_xsl = new MM_XSLTransform();
mm_xsl.setXML("http://www.skilfulminds.com/feed/");
mm_xsl.setXSL("headlines.xsl");
Response.write (mm_xsl.Transform());
%>

The XML Tranform seemed to work correctly at first, except it didn't display in descending order. However, as I add to the blog the feed displayed is not updating either.

Can anyone offer insight into what I'm doing wrong.

The XSL Fragment code is below.

___________________________________________________________

<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://www.skilfulminds.com/feed/" -->
<!DOCTYPE xsl:stylesheet  [
<!ENTITY nbsp   "&#160;">
<!ENTITY copy   "&#169;">
<!ENTITY reg    "&#174;">
<!ENTITY trade  "&#8482;">
<!ENTITY mdash  "&#8212;">
<!ENTITY ldquo  "&#8220;">
<!ENTITY rdquo  "&#8221;">
<!ENTITY pound  "&#163;">
<!ENTITY yen    "&#165;">
<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html" encoding="utf-8"/>
  <xsl:param name="ItemsPerPage" select="5" />
<xsl:template match="/">
  <xsl:for-each select="rss/channel/item[position() &lt;= $ItemsPerPage]">
  <xsl:sort select="pubDate" order="descending" />
    <p><a href="{link}" target="_blank"><xsl:value-of select="title"/></a><br />
      by
      <xsl:value-of select="dc:creator"/></p>
    <p><em>Description</em></p>
    <p><xsl:value-of select="description" disable-output-escaping="yes"/> </p>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Thanks in advance,

Larry Irons

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
July 3, 2010

I haven't used XSL Transformations with ASP, but the following XSLT Fragment should do what you want:

<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://www.skilfulminds.com/feed/" -->
<!DOCTYPE xsl:stylesheet  [
     <!ENTITY nbsp   "&#160;">
     <!ENTITY copy   "&#169;">
     <!ENTITY reg    "&#174;">
     <!ENTITY trade  "&#8482;">
     <!ENTITY mdash  "&#8212;">
     <!ENTITY ldquo  "&#8220;">
     <!ENTITY rdquo  "&#8221;">
     <!ENTITY pound  "&#163;">
     <!ENTITY yen    "&#165;">
     <!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="/">
  <xsl:for-each select="rss/channel/item">
    <xsl:if test="position() &lt;= 5">
      <p><a href="{rss/channel/item/link}"><xsl:value-of select="title"/></a> by <xsl:value-of select="dc:creator"/></p>
      <p><strong>Description:</strong> <xsl:value-of select="description" disable-output-escaping="yes"/></p>
    </xsl:if>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>