|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: RE: fn:contains multiple strings to compare with
> 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/
|
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
|

Cart








