1

p.xml

<documents>
  <dblp>
    <inproceedings>
      <author>John Cieslewicz</author>
      <author>Kenneth A. Ross</author>
      <author>Kenneth A. Ross</author>
    </inproceedings>
   </dblp>
   <dblp>
    <inproceedings>
      <author>Yi-Reun Kim</author>
      <author>Kyu-Young Whang</author>
      <author>John Cieslewicz</author>
    </inproceedings>
   </dblp>
 <documents>

我的代码是

for $c in doc("C:\Users\User\Desktop\p.xml")//documents/dblp/inproceedings
where fn:count($c/author) != fn:count(fn:distinct-values($c/author))
return $c/author

我需要John CieslewiczKenneth A. Ross作为结果,但它只显示Kenneth A. Ross

4

1 回答 1

1

如果要列出多次出现的作者,则需要在所有作者列表中全局计算他们,而不是在程序的作者列表中本地计算:

let $docs := doc("C:\Users\User\Desktop\p.xml")/documents, 
    $authors := $docs//author,
    $distinct-authors := distinct-values($authors)
for $author in $distinct-authors
where count($authors[. eq $author]) > 1 
return $author
于 2013-11-28T11:17:01.943 回答