[xquery-talk] Help With Typeswitch Expression?

Wei, Alice J. ajwei at indiana.edu
Thu Mar 27 10:43:40 PST 2008


Hi, Jonathan:

  Thanks for the clarification, I think I will have to stick with if then else.

  Perhaps, what I was suggesting with case switching can be something built in when XQuery 2.0 is released.

Thanks for your help.

Alice
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu
________________________________________
From: Jonathan Robie [jonathan.robie at redhat.com]
Sent: Thursday, March 27, 2008 10:32 AM
To: Wei, Alice J.
Cc: talk at x-query.com
Subject: Re: [xquery-talk] Help With Typeswitch Expression?

Hi Alice,

Stick with if then else.

Typeswitch has to do with XML Schema types. Judging by the questions you
generally ask, typeswitch is not something you need to be worrying about
for a while.

It would be nice if XQuery had a switch statement, which is what you
seem to be looking for, but it does not.

Jonathan

Wei, Alice J. wrote:
> Hi, XQueriers:
>
>   I am not sure if I should be using a typeswitch expression here.
>
> My XQuery snippet:
>
> if (($type ne "") and ($type2 eq "greeting") and ($type3 eq "") and ($type4 eq ""))
> then <div><p>This is what you typed: {$type2} : {$type}</p[></div>
> else <p>You have not typed anything!</p>
>
> This is what I tried:
>
> typeswitch($type)
> case $h as xs:anyAtomicType)
> return
> <div><p>This is what you typed: {$type2} : {$type}</p[></div>
>
> The problem in this code is that I could not get it to say that I want $type2 to match "greeting."
> I have also tried using a let clause declare that $type, $type2, $type3 and $type4 are actually external variables from the http request, which this failed since it appears that typeswitch does not allow me to put anything before its function.
>
> Have I misunderstood what typeswitch is meant to do? And, to solve the issue from encoding too many of these if else statements, what are the other options?
>
> Thanks for your help.
>
> Alice
> ======================================================
> Alice Wei
> MIS 2008
> School of Library and Information Science
> Indiana University Bloomington
> ajwei at indiana.edu
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>




More information about the talk mailing list