-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccept-sum-2.xq
30 lines (26 loc) · 1.14 KB
/
accept-sum-2.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let $list-1 := <list>{
for $x in collection('articles')//*:article
let $b := $x/base-uri()
order by $b
return <item>{$b}</item>
}</list>
let $list := <list>{
for $x in $list-1/*:item
let $id := substring-before(substring-after($x,'/articles/elife-'),'-v')
return
if (substring-before(substring-after($x/following-sibling::*:item[1],'/articles/elife-'),'-v') = $id) then ()
else <item>{$x/string()}</item>
}</list>
let $csv :=
<csv>{(
<record><entry>{'doi'}</entry><entry>{'Acceptance summary?'}</entry></record>
,
for $x in collection('articles')//*:article[*:sub-article and *:body and base-uri()=$list//*:item/text()]
let $doi := ('http://doi.org/'||$x/*:front/*:article-meta//*:article-id[@pub-id-type="doi"])
return
if ($x//*:sub-article[contains(.,'Acceptance summary') or contains(.,'Acceptance Summary')])
then <record><entry>{$doi}</entry><entry>{'yes'}</entry></record>
else <record><entry>{$doi}</entry><entry>{'no'}</entry></record>
)
} </csv>
return file:write('/Users/fredatherden/Desktop/accept-sum.csv',$csv, map{'method':'csv'})