xml - Create a list using a for in XQuery 1.0 -
i create list of element using in example:
for $ingr in distinct-values(//ingredient/name) let $res := ( $res2 in //restaurant return if( $ingr2 in $res2/dish/ingredient/name satisfies $ingr2 eq $ingr ) then( $res2 ) else() ) return $ingr, $res
what want obtain is: for each ingredient return list of restaurants use it
. don't understand problem?
here can see example: http://www.xpathtester.com/xquery/0c8f9699df404020afd07ff9f9517a46
it keep saying: error - variable $res has not been declared
your expression read (for ... let ... return $ingr), ($res)
. means $res
@ end considered different expression separate previous flwor expression, hence undeclared variable error.
you can use parentheses alter unwanted grouping :
for $ingr in distinct-values(//ingredient/name) let $res := ( $res2 in //restaurant return if( $ingr2 in $res2/dish/ingredient/name satisfies $ingr2 eq $ingr ) then( $res2 ) else() ) return ($ingr, $res)
Comments
Post a Comment