XML: Return elements of a sequence that occur certain number of times

后端 未结 2 420
傲寒
傲寒 2021-01-28 08:23

I have an XML file with information on movies. I want my expression to return the directors in the XML that have directed more than 1 movie.

What I have now is:

相关标签:
2条回答
  • 2021-01-28 08:52

    Try this:

    for $director in distinct-values(//director)
    where count(//video[director = $director]) > 1
    return $director
    
    0 讨论(0)
  • 2021-01-28 09:07

    I solved the problem with the following code:

    let $directors := distinct-values(
    for $director in //director
    where count(result/videos/video[director = $director]) > 1
    return $director
    )
    return $directors
    
    0 讨论(0)
提交回复
热议问题