Subject: RE: [xsl] RE: fn:contains multiple strings to compare with From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 5 Nov 2008 08:40:53 -0000 |
> 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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: fn:contains multiple stri, Tony Nassar | Thread | Re: [xsl] XPath "//", speed, and Sa, Tony Graham |
[xsl] how to do this, amit singh | Date | RE: [xsl] how to do this, Michael Kay |
Month |