> { if (count($paths[.=$papa]) = 0) then let $rat:=1 else let > $rat:=count($paths[.=$papa]) return That's declaring two separate variables, each with the same name, which immediately go out of scope. You need let $rat := (if (xxxx = 0) then 1 else (xxxx)) return.... Michael Kay http://www.saxonica.com/