質問

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>

my code is

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

I need John Cieslewicz and Kenneth A. Ross in result but its shows only Kenneth A. Ross

役に立ちましたか?

解決

If you want to list authors who appear multiple times, you need to count them globally in the list of all authors, not locally in the list of authors of a proceeding:

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top