|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Help With Typeswitch Expression?Wei, Alice J. ajwei at indiana.eduThu 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 http://x-query.com/mailman/listinfo/talk ________________________________________ From: Jonathan Robie [http://x-query.com/mailman/listinfo/talk] Sent: Thursday, March 27, 2008 10:32 AM To: Wei, Alice J. Cc: http://x-query.com/mailman/listinfo/talk Subject: Re: 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 > http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > http://x-query.com/mailman/listinfo/talk > http://x-query.com/mailman/listinfo/talk >
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






