This content has been marked as final. Show 7 replies
I don't understand what you intend to do by putting a whitespace there.
Could you explain?
If you want to test for $TRP = (COLIS or FRC), I'm afraid it's not possible that way :
You'll have to test both explicitely :
typeswitch ($TRP) case element (POSTE) return (...) case element (COLIS) return (...) case element (FRC) return (...) default return (...)
Hi, I meant a case which contains a blank (a b), (first post); ...
when you put something like that, it generates an error
case (first post) return (...)
Do you have an idea
I meant a case which contains a blank (a b), (first post); ...Yes , I understand what you're doing but not why you're doing it.
What do you think "case element(a b) return ..." means?
See the link I gave above for allowed syntaxes.
Maybe I am wrong, but I have a couple of cases to match against a value,
Some of them, are composed with a blank like what I mentionned,(first part)
Is it the way to do (with typeswitch) instead of dosen of (if, then, else)
I resolved it,
Thanks for your help
OK, now I understand what you're after.
The typeswitch expression is not for testing values, but item types (called SequenceType in the specs).
For example :
where $doc =
for $i in $doc/root/* return typeswitch ($i) case element(TEST) return <result>I am a TEST element</result> default return <result>I am unknown</result>
will produce :
XQuery doesn't provide switch-case statement for values like we have for other languages.
<result>I am a TEST element</result> <result>I am unknown</result> <result>I am a TEST element</result>
Thanks for your help. I close the post