[xquery-talk] Problems with string testing in if
Philippe Michiels
philippe.michiels at ua.ac.be
Tue Jun 1 09:59:38 PDT 2004
> Thank you both for the help. Unfortunately none of the suggestions
> worked, although they changed the behaviour of the function: now it
> always returns "test" (except when called with the locale no_NO from
> Safari (MacOS X), then it returns "nor" as expected; the same locale
> from Mozilla returns "test", though). That is, in all but one case it
> goes directly to the last else clause.
I do not think there is something wrong with your function. I tested this
function with Galax and it seems to work fine. The attached query file
results in
"nor"
"fin"
"sme"
"eng"
"sms"
Maybe it's a bug?
Ph
--
Philippe Michiels
Universiteit Antwerpen
ADReM (Advanced Database Research and Modelling)
http://www.adrem.ua.ac.be/~michiels
-------------- next part --------------
(: Convert incoming locale strings to 3-letter language codes (ISO 639):)
declare function local:locale2lang($locale as xs:string) as xs:string
{
let $lang := substring-before($locale,"_")
return
if ($lang = "no" or $lang = "nn" or $lang = "nb" ) then "nor"
else if ($lang = "se") then "sme"
else if ($lang = "sv") then "swe"
else if ($lang = "fi") then "fin"
else if ($lang = "en") then "eng"
else if ($lang = "smi") then "sme"
else if ($lang = "sme" or $lang = "sma" or
$lang = "smn" or $lang= "smj" or
$lang = "sms" or $lang = "sme" or
$lang = "nor" or $lang = "swe" or
$lang = "fin" or $lang = "eng") then
$lang
else "test"
};
local:locale2lang("nn_NO");
local:locale2lang("fi_FI");
local:locale2lang("se_SE");
local:locale2lang("en_EN");
local:locale2lang("sms_SM");
More information about the talk
mailing list