简体   繁体   中英

XQuery Creating a Variable that contains a List Condition

I am very new to Xquery. Here's what I am trying to do:

let $numbers := ('1', '2', '3', '6')
let $answers := $document//answer[number/@number = 'ABC' and ........]
for $answer in $answers
    let...

After the and clause I have tried to put a condition for all the numbers in my numbers variable to create the answers variable.

and number[@number = $numbers]

And then later loop through all the answers that match 1, 2, 3 and 6.

Should I already be looping through numbers variable to create this answers variable that contains all my number picks?

Thanks in advance!

As you suggest I would add a loop and a join like this:

let $numbers := ('1', '2', '3', '6')
let $answers := $document//answer[number/@number = 'ABC']

for $number in $numbers
   for $answer in $answers[number[@number = $number]]
    let...

or shorter:

let $numbers := ('1', '2', '3', '6')

for $number in $numbers
   for $answer in $document//answer[number/@number = 'ABC' and number[@number = $number]]
    let...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM