Subject: RE: [xsl] Filtering RSS feed with xsl based on presence of certain words in description From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 28 Jan 2009 12:25:07 -0000 |
> 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, XSLT 1.0 isn't known for its succinctness. In 2.0 I would do: <xsl:variable name="keywords" as="xs:string*"> <w>word1</w> <w>word2</w> <w>word3</w> </xsl:variable> <xsl:function name="f:matches-keyword" as="xs:boolean"> <xsl:param name="in" as="xs:string"/> <xsl:sequence select="some $w in $keywords satisfies contains($in, $w)"/> </xsl:function> <xsl:template match="item[f:matches-keyword(description)]"> .. process the item .. </xsl:template> <xsl:template match="item"> .. do nothing .. </xsl:template> Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Filtering RSS feed with xsl b, jo lemen | Thread | Re: [xsl] Filtering RSS feed with x, ac |
[xsl] Filtering RSS feed with xsl b, jo lemen | Date | Re: [xsl] Filtering RSS feed with x, ac |
Month |