Question

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

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top