From: Jens <je...@fa...> - 2005-03-23 15:47:29
|
> > fn:round() returns what looks like xs:decimal even though it should(?) > > return an integer, at least when looking at the examples in the XQuery > > function specs: > > > > > o fn:round(2.5) returns 3. > > > o fn:round(2.4999) returns 2. > > In your query, it returns an xs:double, which seems to be correct: the input > values to fn:max have type xdt:untypedAtomic, which have to be converted to > xs:double according to the spec. fn:round() thus gets an xs:double as input > and returns a value of the same type. That's correct as far as I can see. > > The extra ".0" is added by Java's Double.toString() method. It should be > possible to fix this by changing line 74 of > src/org/exist/xquery/value/DoubleValue (method getStringValue) as follows: > > return s.substring(0, len - 2); Looks like a quick and dirty hack ;-). IMHO it would be better to cast to the expected type at the right point: let $r := document('/db/ordbase/terms/SD-terms/termcenter.xml')//entry/@id return xs:integer(fn:round( fn:max( $r ))) or like this return fn:round( fn:max( for $i in $r return xs:integer($i) ) ) Nevertheless I can't see any reason why to round an integer value? Jens |