Dear BaseXer's, The following query for $xqV1 in collection( 'localex' )//kRecord let $xqV2 := $xqV1/*[1] , $xqV7 := $xqV1/*[2] where ( count($xqV1/*) = 2 ) and ( for $xqV3 in $xqV1/node let $xqV4 := $xqV3/*[1] where ( count($xqV3/*) = 1 ) and ( for $xqV5 in $xqV3/uid let $xqV6 := $xqV5/*[1] where ( count($xqV5/*) = 1 ) and ( ( ( $xqV6 = <string>uid.value</string> ) or ( fn:string( fn:node-name( $xqV6 ) ) = "var" ) ) ) and ( $xqV4 = $xqV5 ) return $xqV5 ) and ( $xqV2 = $xqV3 ) return $xqV3 ) return $xqV1 returns our expected result, while for $xqV1 in collection( 'localex' )//kRecord let $xqV2 := $xqV1/*[1] , $xqV7 := $xqV1/*[2] where ( count($xqV1/*) = 2 ) and ( for $xqV3 in $xqV1/node let $xqV4 := $xqV3/*[1] where ( count($xqV3/*) = 1 ) and ( for $xqV5 in $xqV3/uid let $xqV6 := $xqV5/*[1] where ( count($xqV5/*) = 1 ) and ( ( ( $xqV6 = <string>uid.value</string> ) or ( fn:string( fn:node-name( $xqV6 ) ) = "var" ) ) ) and ( $xqV4 = $xqV5 ) return $xqV5 ) and ( $xqV2 = $xqV3 ) return $xqV3 ) and ( true ) return $xqV1 which is the same query with an 'and ( true )' added to the outer where-clause returns no results. Should we expect that for ... let ... where C return ... == for ... let ... where C and ( true ) return ... ? Best wishes, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 7329 39th Ave SW Seattle, WA 98136 +1 206.650.3740 http://biosimilarity.blogspot.com