문제

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