I don't know if "bug" is the right term, but certainly "limitation".
This is still the case in ML 4.1-1.

And this workaround is not even possible:

  if ("1999-01-01TTT0:0:0" castable as xs:dateTime)
  then xs:dateTime("1999-01-01TTT0:0:0")
  else ()

It still throws an XDMP-CAST error, meaning the "then" result is being
evaluated in a static context and not optimized away. (In eXist and
Saxon XQuery, by contrast, the query succeeds.)

So I think you'd have to go with a workaround like

let $date := "1999-01-01TTT0:0:0"
let $castable := $date castable as xs:dateTime
return
  if ($castable)
  then xs:dateTime($date)
  else ()


On Fri, 4 Sep 2009, Paul M wrote:

> Not sure if bug, need workaround ideas regardless..
> 3.2-10
>
> let $x := try{xs:dateTime("1999-01-01TTT0:0:0")} catch($ex) {()}
> let $y := try{ 2 div 0 } catch($ex) {()}
> return $x
>
> Return a dateTime if possible. Otherwise, return empty sequence.
> The second try-catch works. The first does not.
>
> What would you do if you knew one of your casts may fail? My only idea is 
> regexp?
>
>
>
>

-- 
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: [email protected]   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to