Re: [xsl] Matching for strings...

Subject: Re: [xsl] Matching for strings...
From: "Bob Portnell" <simply.bobp@xxxxxxxxx>
Date: Wed, 6 Sep 2006 10:31:53 -0700
Ah, so. Yup, contains() is a better fit for what I want to do. Thanks
to Andrew and David for pointing it out, and to David for clarifying
the "best uses" on assorted string functions.

I've gotten that trigger to work correctly, but now I can't get a
nigh-identical trigger to operate further along in the transform.
Which makes me believe I've got a context problem someplace and I must
cogitate upon it.

Thanks, again! Clever and patient assistance to be found here as always.

Bob P
simply.bobp@xxxxxxxxx

On 9/6/06, David Carlisle <davidc@xxxxxxxxx> wrote:

> 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