0
{
    for $movie in distinct-values(doc("movies.xml")/movies/movie)
    where count(doc("movies.xml")/movies/movie[title=$movie/title]) = count(distinct-values(doc("movies.xml")/movies/movie/source))
    return
    <title> {$movie/title} </title> 
}

この特定のクエリでは、次のことを試みています。「映画」ドキュメントのすべてのソースから提供されている映画のタイトルを検索します。where 句の行でエラーが発生します。エラーは次のとおりです。「/」の最初のオペランドの必須項目タイプは node() です。指定された値の項目タイプは xs:anyAtomicType です

4

1 に答える 1

0

問題は、distinct-values()異なる文字列値を返すため、文字列で xpath 式を使用しようとしていることです。$movie/titlewhich が無効であると評価され(xs:string)/title、例外がスローされます。

しかし、私があなたの目標を理解している方法では、そのクエリがあなたが望む結果を返すとは思いません。すべてのソースから提供されている映画のタイトルを返すには、次のソリューションを試してください。

let $sources-distinct-all := count(distinct-values(doc("movies.xml")/movies/movie/source))
for $title in distinct-values(doc("movies.xml")/movies/movie/title) 
let $sources-distinct-movie := count(distinct-values(doc("movies.xml")/movies/movie[title eq $title]/source))
where ($sources-distinct-all eq $sources-distinct-movie)
return $title
于 2012-10-31T19:08:09.573 に答える