Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2009, 03:50 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default limiting RSS records to 5

Hi! I am new to XSLT and am using Dreamweaver to generate this code, which works great, except that I need to limit the number of records pulled from an RSS feed to 6. Can you tell me how/where in the code to do this? Any help greatly appreciated.
Code:
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://live.psu.edu/tagrss/Research" --><!DOCTYPE xsl:stylesheet  [
    <!ENTITY nbsp   " ">
    <!ENTITY copy   "©">
    <!ENTITY reg    "®">
    <!ENTITY trade  "™">
    <!ENTITY mdash  "—">
    <!ENTITY ldquo  "“">
    <!ENTITY rdquo  "”"> 
    <!ENTITY pound  "£">
    <!ENTITY yen    "Â¥">
    <!ENTITY euro   "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="/"><style type="text/css">
<xsl:comment>
.rss_title {
    font: bold 100% Arial, Helvetica, sans-serif;
}
.rss_description {
    font: 90% Arial, Helvetica, sans-serif;
}
.rss_link {
    font: 80% Arial, Helvetica, sans-serif;
    text-decoration: none;
}
</xsl:comment>
</style>

  <xsl:for-each select="rss/channel/item">
    <span class="rss_title"><xsl:value-of select="title"/></span><br />
    <span class="rss_description"><xsl:value-of select="description" disable-output-escaping="yes"/></span>
    
            <a href="{../link}" target="_blank" class="rss_link">Read on...<br />
            <br />
</a>
  </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Last edited by sbrennen; March 24th, 2009 at 03:52 PM.. Reason: needed to insert code tags for formatting
 
Old March 24th, 2009, 03:57 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:for-each select="(rss/channel/item)[position() &lt; 6]">
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
sbrennen (March 24th, 2009)
 
Old March 24th, 2009, 04:35 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thank you! and follow up question

Do you happen to know why I'm not getting the correct link that corresponds with the title and description? URL from first link is repeating in all of the stories.
 
Old March 24th, 2009, 04:38 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default nevermind

Michael: Just figured out the last problem on my own. Thanks again for your quick answer!





Similar Threads
Thread Thread Starter Forum Replies Last Post
limiting/hiding records w/null values louisvillelivin Crystal Reports 0 February 5th, 2007 10:43 AM
Limiting Document Versions dasani20oz SharePoint Admin 1 October 23rd, 2006 03:55 PM
Bandwidth Control or Limiting using JSP draggy Pro JSP 3 July 21st, 2006 02:58 PM
Limiting a TextBox MultLine gmachado VS.NET 2002/2003 1 November 2nd, 2003 12:04 AM
Limiting MySQL data maedhros Beginning PHP 1 August 2nd, 2003 07:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.