[xquery-talk] Problems with string testing in if
Sjur Nørstebø Moshagen
sjur.moshagen at kolumbus.fi
Tue Jun 1 01:08:20 PDT 2004
Hello,
I'm new to this list, my apologies if this posting is outside the
intended scope.
I need to query a set of localised documents identified with ISO 639-2
3-letter codes, and I have written the function cited below to convert
incoming locale strings to the equivalent 3-letter codes for the
languages in question.
The problem is it does not work as expected. So far I have tried the
following:
input output
----- ------
no nor
se nor
sme nor
The function is:
(: Convert incoming locale strings to 3-letter language codes (ISO 639)
:)
declare function fn:locale2lang($locale as xs:string) as xs:string
{
let $lang := substring-before($locale,'_')
return
if ($lang = "no" or "nn" or "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 "sma" or "smn" or
"smj" or "sms" or "sme" or
"nor" or "swe" or "fin" or "eng") then $lang
else "test" (: the default lang here later, now 'test' for debugging
purposes :)
};
I'm running the query/function against/in eXist, but I believe it is
more my understanding of XQuery than anything else that's missing, thus
posting on this list. I would appreciate any help.
Regards,
Sjur N. Moshagen
More information about the talk
mailing list