|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Filtering RSS feed with xsl based on presence of certa
I'm trying to filter an external rss feed using xls so that only those feed items that contain at least one of a list of words are selected. The code below does that, but I'm wondering if there isn't a more succint and easier to maintain way, for example using an xsl include, putting the list in an external xml file, using variables or parameters .. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1" /> <xsl:template match="*"> <xsl:for-each select="//item"> <xsl:if test="contains(description, 'word1') or contains(description, 'word2') or contains(description, 'word3') or contains(description, 'word4') or contains(description, 'word5') <--- plus 20 or more other words --> <xsl:if test="position()<10"> <p> <strong><xsl:value-of select="title" /></strong> <xsl:text disable-output-escaping="yes"><br /></xsl:text> <em> <xsl:variable name="convertdate" select="pubDate" /> <xsl:variable name="pubday" select="substring($convertdate, 6,2)" /> <xsl:value-of select="$pubday" /> <xsl:text>/</xsl:text> <xsl:variable name="pubmonth" select="substring($convertdate, 9,3)" /> <xsl:choose> <xsl:when test="$pubmonth='Jan'">01</xsl:when> <xsl:when test="$pubmonth='Feb'">02</xsl:when> <xsl:when test="$pubmonth='Mar'">03</xsl:when> <xsl:when test="$pubmonth='Apr'">04</xsl:when> <xsl:when test="$pubmonth='May'">05</xsl:when> <xsl:when test="$pubmonth='Jun'">06</xsl:when> <xsl:when test="$pubmonth='Jul'">07</xsl:when> <xsl:when test="$pubmonth='Aug'">08</xsl:when> <xsl:when test="$pubmonth='Sep'">09</xsl:when> <xsl:when test="$pubmonth='Oct'">10</xsl:when> <xsl:when test="$pubmonth='Nov'">11</xsl:when> <xsl:when test="$pubmonth='Dec'">12</xsl:when> </xsl:choose> <xsl:variable name="pubyear" select="substring($convertdate, 13,4)" /> <xsl:text>/</xsl:text> <xsl:value-of select="$pubyear" /> </em> <xsl:text disable-output-escaping="yes"><br /></xsl:text> <xsl:value-of select="description" disable-output-escaping="yes" /> <xsl:text> .. </xsl:text> <a> <xsl:attribute name="href"> <xsl:value-of select="link" /> </xsl:attribute> <xsl:attribute name="title">full story</xsl:attribute> <xsl:text>full story</xsl:text> </a> </p> </xsl:if> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> -- _______________________________________________ Surf the Web in a faster, safer and easier way: Download Opera 9 at http://www.opera.com Powered by Outblaze
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






