Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] fn:contains multiple strings to compare with [Thread Next] RE: [xsl] RE: fn:contains multiple strings to compare withTo: Date: 11/5/2008 8:41:00 AM > You could use a trick. Sequences returned from a sequence
> expression are always flattened and concatenated. So:
>
> for $city in ('Hamburg', 'Coblenz', 'Aachen') return (if
> (contains('Hamburger', $city)) then true() else ())
>
> ...returns true(), because the empty sequences are simply
> discarded.
Not a good idea. If the input was "von Hamburg nach Aachen" the result would
be (true(), true()), and applying boolean() to that result gives an error.
And you don't need a trick here anyway, because
some $city in ('Hamburg', 'Coblenz', 'Aachen') satisfies (contains($input,
$city))
solves the problem perfectly well.
Or, if you prefer brevity, you can write
exists(('Hamburg', 'Coblenz', 'Aachen')[contains($input, .)])
Michael Kay
http://www.saxonica.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
