In this expression:
 let maxCount := floor(($maxValue - $minValue)/$delta)
your first error is that you seem to be using "/" as a division operator. Use div for division.
Also you seem to have omitted the "$".
To cast a double to an integer, use
let $maxCount := xs:integer(($maxValue - $minValue) div $delta)
The floor() function returns a value of the same type as its argument. (This is because the floor() of a very large double may be outside the range of values supported by the integer data type).
Michael Kay
-----Original Message-----
From: [] On Behalf Of Oswald Campesato
Sent: 30 August 2003 12:06
Subject: [saxon] casting double to integer

Hello, everyone:
I have a simple question:  how do I cast a quotient
of two numbers (both retrieved from an XML file) as
an integer in a 'for' loop?
  let maxValue := doc("test1.xml")/data/maxValue
  let minValue  := doc("test1.xml")/data/minValue
  let delta         := doc("test1.xml")/data/delta
  (: 'maxCount' is the upper limit in a 'for' loop :)
  let maxCount := floor(($maxValue - $minValue)/$delta)
  for $index in 0 to $maxCount
  return $index
The previous code results in the following error message:
Error on line 54
  Required type of second operand of 'to' is xs:integer;
supplied value is xs:double
I noticed the "define variable" construct, but how can
this be used in conjunction with the preceding code?
Suggestions are welcome...

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software