p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   XPath multiple conditional statement (http://p2p.wrox.com/showthread.php?t=77677)

geek.shrek January 5th, 2010 07:09 PM

XPath multiple conditional statement
 
Hi,

I'm using xpath 2.0 and trying to use a conditional statement. But it seems like the conditional only gone through
[CODE]
if conditionA then result
else if conditionB then result
else result
[CODE]

I would like to achieve something like
[CODE]
if conditionA then result
else if conditionB then result
else if conditionC then result
else if conditionD then result
else if conditionE then result
else result
[CODE]

Here is my code:
[CODE]

if ($start-time >= xs:time('01:00:00') and $start-time <= xs:time('09:00:00')) then 'Morning'
else if ($start-time > xs:time('09:00:00') and $start-time <= xs:time('17:00:00')) then 'Afternoon'
else if ($start-time > xs:time('17:00:00') and $start-time <= xs:time('24:00:00')) then 'Night'
else if ($start-time > xs:time('00:00:00') and $start-time < xs:time('01:00:00')) then 'In between Night and Day'
else 'Continue or Undefined'

[CODE]

Can someone tell me what is wrong with my conditional statement.

Thanks,

mhkay January 5th, 2010 07:19 PM

Comparisons of time values can work in peculiar ways, because time is essentially cyclic. The value 24:00:00 is particularly dangerous, because it is a synonym of 00:00:00. Try changing it from 24:00:00 to 23:59:59.999.

geek.shrek January 5th, 2010 07:53 PM

Thank you very much :). It works.


All times are GMT -4. The time now is 04:56 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.