[xquery-talk] Help With Typeswitch Expression?

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


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



More information about the talk mailing list