Clarification request on XPath/XQuery functions and operators regarding implicit casts

I would kindly ask for advice on the following questions regarding 
implicit casts and type promotions in XPath/XQuery functions


1) For instance, fn:year-from-dateTime
(http://www.w3.org/TR/xpath-functions/#func-year-from-dateTime)
does not mention any implicit casts in its definition.
Does that imply a type error if I call

  fn:year-from-dateTime(s)

with an xs:string value s as parameter, even if s is in the lexical 
space of xs:dateTime or is a cast here implicit?

On the other hand, fn:years-from-duration
(http://www.w3.org/TR/xpath-functions/#func-year-from-dateTime)
mentions explicitly casting in its definition:

"The result is obtained by casting $arg to an xs:yearMonthDuration (see 
17.1.4 Casting to duration types) and then computing the years component 
as described in 10.3.1.3 Canonical representation."

Would that imply that fn:years-from-duration(s)
would accept an xs:string s castable to xs:yearMonthDuration
as argument?

In this case is this different treatment of the extraction functions
for years from dateTime and duration intended?

2) Similarly,
op:divide-yearMonthDuration
(http://www.w3.org/TR/xpath-functions/#func-divide-yearMonthDuration)
accepts as second argument xs:double.

Again the question is whether casting here is implicit, as e.g. the 
example suggests:

op:divide-yearMonthDuration(xs:yearMonthDuration("P2Y11M"), 1.5)

where 1.5 is a decimal value, isn't it?


In general, I would like to find where in the spec I would find hints on 
whether conversions in functions and operators are meant to be implicit 
or not, and, if they are, then why in some cases, e.g.
fn:years-from-duration
casting is mentioned explicitly?

Thanks for clarification,
Axel Polleres

-- 
Dr. Axel Polleres
Digital Enterprise Research Institute, National University of Ireland, 
Galway
email: axel.polleres@deri.org  url: http://www.polleres.net/

Received on Tuesday, 12 May 2009 22:48:55 UTC