[xquery-talk] making a search case-insensitive

Frans Englich frans.englich at telia.com
Thu Jul 27 15:08:10 PDT 2006

On Thursday 27 July 2006 08:55, Michael Kay wrote:
> The correct way to do this is to search using a caseblind collation, but
> I've no idea whether that's a feature that your product supports.
> $keyword and upper-case($keyword) are both strings; you can't apply the
> "or" operator to two strings, it works only with boolean operands. So
> "$keyword or upper-case($keyword)" will give you a type error.
> Similarly, te contains() function tests whether one string is a substring
> of another. I suspect when you write contains($text, $kwds) you are
> imagining that $kwds is a set of strings and that the function will return
> true if $text contains any of them.
> So:
> (a) to make $kwds be a set (sequence) of strings, do
> $kwds := ($keyword, upper-case($keyword), lower-case($keyword), $mixedkwd)
> (b) to test if $text contains any of them, do
> some $k in $kwds satisfies contains($text, $k)
> But wouldn't it be easier simply to test
> contains(upper-case($text), upper-case($keyword))

Perhaps implementations can optimize this by rewriting for example 
'upper-case($a) eq upper-case($b)' to a case-insensitive comparison, and 
similar cases involving compare(), contains, upper-case(), and so on.

I haven't looked at the details of this. E.g, whether it can be done that way 
while staying conformant. Flag 'i' for regexp patterns seems relevant.

Does anyone do that? Seems relevant in particular for XSL-T 1.0 stylsheets.



More information about the talk mailing list