我是 XQuery 的新手,我的问题是关于不同的值,我正在使用以下代码来检索电影评论者
xquery version "1.0";
declare boundary-space preserve;
<result>
{for $reviews in doc("reviews.xml")/reviews/review,
$movie in doc("movies.xml")/movies/movie
where $reviews/movie_title = $movie/movie_title
and $movie//movie_genre = "Drama"
and $movie//month > 6
order by $reviews/movie_reviewer descending
return
(<reviewer>{distinct-values($reviews/movie_reviewer)}</reviewer>, '
')
}
</result>
后来我将代码更改为
xquery version "1.0";
declare boundary-space preserve;
<result>
{for $reviews in doc("reviews.xml")/reviews/review,
$movie in doc("movies.xml")/movies/movie
where $reviews/movie_title = $movie/movie_title
and $movie//movie_genre = "Drama"
and $movie//month > 6
return
{for $content in distinct-values($reviews/movie_reviewer)
order by $content descending
return (<reviewer>{$content}</reviewer>, '
')}
}
</result>
但我得到了类似的结果
<result>
<reviewer>Wesley Barry</reviewer>
<reviewer>Michael Gordon</reviewer>
<reviewer>Michael Gordon</reviewer>
<reviewer>Michael Gordon</reviewer>
<reviewer>John Frankenheimer</reviewer>
<reviewer>J. Lee Thompson</reviewer>
<reviewer>J. Lee Thompson</reviewer>
<reviewer>Charles Walters</reviewer>
<reviewer>Charles Walters</reviewer>
</result>
我怎样才能使结果像
<result>
<reviewer>Wesley Barry</reviewer>
<reviewer>Michael Gordon</reviewer>
<reviewer>John Frankenheimer</reviewer>
<reviewer>J. Lee Thompson</reviewer>
<reviewer>Charles Walters</reviewer>
</result>
? 我知道这是非常基本的,但我就是不明白这一点