[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

xqts:CastableAs648 variable castable as

Michael Kay mike at saxonica.com
Tue Mar 6 10:16:26 PST 2007


  xqts:CastableAs648 variable castable as
> 
> I know Saxon honours this behaviour of returning false for 
> this, but I still find it a bit odd to not be able to test 
> without casting the referenced value.
> 
> let $var := "ABC" return $var castable as xs:QName
> 
> I would be glad if someone could give their opinion on this 
> issue or point me to any previous discussion.

The restriction that "cast as xs:QName" (and therefore "castable as
xs:QName") should only work on string literals is a rather odd one, in that
it appears to violate the principle of orthogonality. The reason for the
restriction was the feeling that it didn't make sense for the result of a
cast to be context-sensitive: it means that an optimizer, before rearranging
an expression, has to do special checks that it isn't moving a cast to a
place where the namespace context is different. In fact I think the
rationale used at the time is a little questionable, but it's a restriction
that does no harm: if you want to construct a QName, then you ought to know
what the namespace and local name components of the QName are, and you can
then use the fn:QName() function to construct it unambiguously.

Or perhaps you're pointing to a slightly different oddity, which is that
($var castable as xs:QName) feels more like a syntax error than an
expression that should return false. Well, the problem here is where to draw
the line. We decided that "castable as" should always return true or false,
and that we wouldn't try to make a distinction between cases where the cast
would fail as a type error (invalid input type) and those where it would
fail as a dynamic error (invalid input value), because we felt that
distinction was too subtle to impose on users. Then we simply extrapolated
that policy to this case.

Michael Kay
http://www.saxonica.com/



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.