Re: [xsl] Matching for strings...

Subject: Re: [xsl] Matching for strings...
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 6 Sep 2006 16:49:58 +0100
> Well, the Cookbook didn't help with this problem, or at least not that
> I saw.

Most books (Apart from MK's) are XSLT1 (which is still the official
version) but you appear to be using XSLT2 draft.


> I want to find <program> elements whose <title> or <subtitle> or
> <description> might contain the string I've stowed in the variable
> $target.
> <xsl:if test="matches(normalize-space(//tv:program),$target)">

do you mean contains (for which the contains() function would be most
natural, or equal (when you could use =) or does $target contain a
regular exprression not a fixed string (in which case you would use
matches())

on the face of it I'd guess you'd want

program[contains(title,$target) or contains(subtitle,$target)]

David

Current Thread