how can deal with a expression??

now i need transfer a expression to XQuery ,but i don’t know how to do?

help me

how declare a variable and how can i orgnize a expression in XQuery? following:

double $xn, $f, $g, $rg, $result

$result = $f + $f * $rg


XQuery is a functional language, i.e. there are no assignments.
The closest XQuery (or rather me using it) can get to what you
want is :

let $f := 17e1
let $g := 13.01
let $rg := 1.2
let $result := $f + $f * $rg
return $result

The types of the variables and all other expressions are
derived from the values provided or calculated.



The version of the Quip engine that i’m using now is
i don’t know this version whether to support the expression what i said.

i had defined a fuction,following:

define function cos( double $x)returns AnyType

let $R1 := -0.1666665668e+0
let $R2 := 0.8333025139e-2
let $R3 := -0.1980741872e-3
let $R4 := 0.2601903036e-5
let $INVSPI := 0.31830988618379067154
let $HALFPI := 1.57079632679489661923
let $C1 := 3.140625
let $C2 := 9.67653589793e-4
let $x := abs($x)
let $n := (($x + $HALFPI) * $INVSPI) + 0.5
let $xn := double($n) - 0.5
let $sign := $n mod 2
let $f := ($x - $xn * $C1) - $xn * $C2
let $g := $f * $f
let $rg := ((($R4 * $g + $R3) * $g + $R2) * $g + $R1) * $g
let $result := $f + $f * $rg
if($sign=1) then -$result else $result


when execute it ,the Quip engine throw a err:
<?xml version="1.0" encoding="UTF-8" ?>

<quip:ExecutionError xmlns:quip=“”>



quip:message<![CDATA[Error (36,1): return clause missing

actual token found: if



Please help me how can i do it ?


Hi nicle,

the problem is exactly described in the message, the return
clause is missing. When using either let or for you need a
return to follow. Your query needs a return preceding the if
clause. Read the chapter about FLWOR expressions in the W3C’s
xquery draft, i.e.