Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Jan 9, 2020
1 parent 315c1ff commit 81f27ca
Show file tree
Hide file tree
Showing 99 changed files with 9,629 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RA-sec-titles.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distinct-values(for $x in collection('articles')//*:article[(descendant::*:subject[text() = ('Research Article', 'Short Report', 'Tools and Resources', 'Research Advance', 'Registered Report', 'Replication Study', 'Research Communication')])]/*:body/*:sec/*:title
return normalize-space($x))
87 changes: 87 additions & 0 deletions acceptance-summaries.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
for $x in collection('articles')//*:article/*:sub-article[1]//*:p
let $no := substring-before(substring-after($x/base-uri(),'/articles/elife-'),'-v')
return
if (matches($x,'^[Aa]cceptance summary[:]?$')) then
if (matches($x/following-sibling::*:p[2],'^Decision letter after peer review[:]?$'))
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
$x/following-sibling::*:p[1]/data(),
'
',
' ---- ',
'
'
)
else if (matches($x/following-sibling::*:p[3],'^Decision letter after peer review[:]?$'))
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
$x/following-sibling::*:p[1]/data(),
$x/following-sibling::*:p[2]/data(),
'
',
' ---- ',
'
'
)
else if (matches($x/following-sibling::*:p[4],'^Decision letter after peer review[:]?$'))
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
$x/following-sibling::*:p[1]/data(),
$x/following-sibling::*:p[2]/data(),
$x/following-sibling::*:p[3]/data(),
'
',
' ---- ',
'
'
)
else if (matches($x/following-sibling::*:p[5],'^Decision letter after peer review[:]?$'))
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
$x/following-sibling::*:p[1]/data(),
$x/following-sibling::*:p[2]/data(),
$x/following-sibling::*:p[3]/data(),
$x/following-sibling::*:p[4]/data(),
'
',
' ---- ',
'
'
)

else if (matches($x/following-sibling::*:p[6],'^Decision letter after peer review[:]?$'))
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
$x/following-sibling::*:p[1]/data(),
$x/following-sibling::*:p[2]/data(),
$x/following-sibling::*:p[3]/data(),
$x/following-sibling::*:p[4]/data(),
$x/following-sibling::*:p[5]/data(),
'
',
' ---- ',
'
'
)
else if (matches($x/following-sibling::*:p[7],'^Decision letter after peer review[:]?$'))
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
$x/following-sibling::*:p[1]/data(),
$x/following-sibling::*:p[2]/data(),
$x/following-sibling::*:p[3]/data(),
$x/following-sibling::*:p[4]/data(),
$x/following-sibling::*:p[5]/data(),
$x/following-sibling::*:p[6]/data(),
'
',
' ---- ',
'
'
)
else if (count($x/following-sibling::*:p)lt 3)
then (
($no||' - '||('https://elifesciences.org/articles/'||$no||'#'||$x/ancestor::*:sub-article/@id)),
'
',
for $y in $x/following-sibling::*:p
return $y/data(),
'
',
' ---- ',
'
'
)
else (($no||' - '||'ERROR'))
else ()

18 changes: 18 additions & 0 deletions add-ids-to-support.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let $x := doc('/Users/fredatherden/Documents/GitHub/jats-support/src/support.sch')

return copy $copy := $x
modify(

for $x in $copy//(*:assert|*:report)
let $r := $x/ancestor::*:pattern/@id
let $pos := count($x/ancestor::*:pattern//*[local-name() = $x/local-name()]) - count($x/following::*[(local-name() = $x/local-name()) and (ancestor::*:pattern/@id = $r)])
return
insert node attribute id {concat($x/ancestor::*:pattern/@id,'-',$x/local-name(),'-',$pos)} as last into $x



)

return

file:write('/Users/fredatherden/Desktop/support.sch',$copy, map{'indent':'no'})
59 changes: 59 additions & 0 deletions add-org-name-tests.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
declare variable $sch := doc('/Users/fredatherden/Documents/GitHub/eLife-JATS-schematron/schematron.sch');
declare variable $base-uri := substring-before(base-uri($sch),'/schematron.sch');

for $x in $sch//*:pattern[@id="org-pattern"]//(*:report|*:assert)
let $org-name := substring-before(substring-after($x,"an organism - '"),"' - but there is n")
let $rule-id := $x/parent::*:rule/@id
let $path := concat($base-uri,'/tests/',$rule-id,'/',$x/@id,'/')
let $pass := concat($path,'pass.xml')
let $fail := concat($path,'fail.xml')
let $pass-element := if ($rule-id = 'org-ref-article-book-title') then
<element-citation publication-type="journal">
<article-title> test <italic>{$org-name}</italic> test </article-title>
</element-citation>
else
<article-meta>
<title-group>
<article-title> test <italic>{$org-name}</italic> test </article-title>
</title-group>
</article-meta>

let $fail-element := if ($rule-id = 'org-ref-article-book-title') then
<element-citation publication-type="journal">
<article-title>{concat(' test ',lower-case($org-name),' test ')}</article-title>
</element-citation>
else
<article-meta>
<title-group>
<article-title>{concat(' test ',lower-case($org-name),' test ')}</article-title>
</title-group>
</article-meta>

let $pi-content := ('SCHSchema="'||$x/@id||'.sch'||'"')
let $comment := comment{concat('Context: ',$x/parent::*:rule/@context/string(),'
Test: ',normalize-space($x/@test/string()))}

let $pass-new :=
(processing-instruction {'oxygen'}{$pi-content},
$comment,
<root xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:ali="http://www.niso.org/schemas/ali/1.0">
<article>
{$pass-element}
</article>
</root>)

let $fail-new :=
(processing-instruction {'oxygen'}{$pi-content},
$comment,
<root xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:ali="http://www.niso.org/schemas/ali/1.0">
<article>
{$fail-element}
</article>
</root>
)
return
(
file:write($pass,$pass-new),
file:write($fail,$fail-new)
)

16 changes: 16 additions & 0 deletions aff-edit-test.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let $xml := doc('/Users/fredatherden/Desktop/elife-49920-vor-r2/elife-49920.xml')

let $new-xml := copy $copy := $xml
modify(
for $x in $copy//*:contrib-group[not(@content-type)]//*:aff
let $dept := $x/*:institution[@content-type="dept"]
let $inst := $x/*:institution[not(@content-type)]
return if ($inst = 'University of Kentucky') then (
replace node $inst with <institution>{concat($dept,', ',$inst)}</institution>,
delete node $dept
)
else ()
)
return $copy

return file:write('Desktop/elife-49920.xml',$new-xml,map{'indent':'no'})
12 changes: 12 additions & 0 deletions aff-tests.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
for $x in collection('articles')//*:contrib-group[not(@content-type)]
let $list :=
<list>{
for $aff in $x/*:aff
let $i := $aff/*:institution[not(@content-type)]
return
if ($i=$aff/preceding-sibling::*:aff/institution[not(@content-type)]) then <item>{$aff}</item>
else ()
}</list>
return
if (count($list//*:item)>4) then $x/base-uri()
else ()
24 changes: 24 additions & 0 deletions alt-group-markup.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
let $xml := doc('/Users/fredatherden/Desktop/elife-42463-v1.xml')

let $copy := copy $copy1 := $xml
modify(
for $x in $copy1//*:contrib-group[@content-type="collab-list"]//*:aff
let $id := generate-id($x)
return insert node attribute id {$id} as first into $x
)


return copy $copy2 := $copy1
modify(
for $x in $copy2//*:contrib-group[@content-type="collab-list"]//*:contrib
return replace value of node $x/@contrib-type with 'collaborator',

for $y in $copy2//*:contrib-group[@content-type="collab-list"]//*:contrib//*:aff
return
(replace node $y with <xref ref-type="aff" rid="{$y/@id}"/>,
insert node $y as last into $y/ancestor::*:contrib-group[@content-type="collab-list"])

)
return $copy2

return $copy
2 changes: 2 additions & 0 deletions article.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
for $x in collection('articles')//*:article[(descendant::*:article-id[@pub-id-type="publisher-id"]= '42955') and descendant::*:body]
return $x
28 changes: 28 additions & 0 deletions award-ids.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
declare function local:get-doi($a){
let $id := $a/ancestor::*:article/descendant::*:article-id[@pub-id-type="publisher-id"][1]
let $version := substring-before(substring-after($a/base-uri(),concat($id,'-')),'.xml')
let $url := concat('https://elifesciences.org/articles/',$id,$version)
return copy $copy := $a
modify(
for $x in $copy/descendant-or-self::*:award-group
return insert node attribute {'url'}{$url} as last into $x
)
return $copy
};




<list xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:ali="http://www.niso.org/schemas/ali/1.0/">{
for $x in collection('articles')//*:article//*:funding-group//*:award-group[*:award-id]
let $id := $x/*:award-id
let $y := replace($id,'[\p{P}\p{N}]|[Gg]rant','')
let $new-x := local:get-doi($x)
return
if (matches($id,'\p{Ll}')) then (
if (string-length($y) < 10) then ()
else $new-x)
else ()
}</list>


78 changes: 78 additions & 0 deletions batch-biorxiv-tranformation-2.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
declare namespace xlink="http://www.w3.org/1999/xlink";
declare namespace mml="http://www.w3.org/1998/Math/MathML";


declare variable $dir := '/Users/fredatherden/Desktop/biorxiv-tranformed/';
declare variable $xsl := doc('/Users/fredatherden/Documents/xsl/biorxiv.xsl');


for $x in collection('biorxiv-xml')//*:article[not(descendant::*:media[@mimetype="video"]) and not(descendant::mml:math) and not(descendant::table) and not(descendant::fig-group) and not(descendant::disp-quote) and (count(descendant::*:mixed-citation[@publication-type!='journal']) le 3)]
let $filename := concat(substring-after($x//*:article-meta/*:article-id[@pub-id-type="doi"],'10.1101/'),'.xml')
let $file := xslt:transform($x, $xsl)

let $file2 :=
copy $copy := $file
modify(

for $x in $copy//*:fig
let $label := if (ends-with($x/*:label,'.')) then concat($x/*:label/text(),' ')
else if (ends-with($x/*:label,'.')) then concat($x/*:label/text(),' ')
else concat($x/*:label,'. ')
return
replace node $x with
<fig id="{$x/@id}">
<caption>
<title>{$label,
$x/*:caption/*:p/(*|text())}</title>
</caption>
<graphic xlink:href="{$x/*:graphic/@xlink:href/string()}" mimetype="image" mime-subtype="tiff" />
</fig>,

for $x in $copy//*:table-wrap
let $label := if (ends-with($x/*:label,'.')) then $x/*:label/text()
else concat($x/*:label,'. ')
return
replace node $x with
<table-wrap id="{$x/@id}">
<caption>
<title>{$label,
$x/*:caption/*:p/(*|text())}</title>
</caption>
<graphic xlink:href="{$x/*:graphic/@xlink:href/string()}" mimetype="image" mime-subtype="tiff" />
</table-wrap>,

for $x in $copy//*:sec[(@sec-type="supplementary-material") and not(child::*[local-name()!='title' and local-name()!='supplementary-material'])]
return
delete node $x,

for $x in $copy//*:article-meta//*:contrib//*:xref[@ref-type="aff"]
let $a := $x/ancestor::*:article-meta//*:aff[@id = $x/@rid]
let $aff := <aff id="{generate-id($x/@rid)}">{
for $y in $a/(*|text())
return
if ($y/local-name()='label') then ()
else $y/data()
}</aff>
return
replace node $x with $aff,

for $x in $copy//*:article-meta//*:aff
return delete node $x,

for $x in $copy//*:back/*:ack
return
if ($x/*:title) then (delete node $x,
insert node <sec>{$x/*}</sec> as last into $x/preceding::body[1])
else (delete node $x,
insert node <sec><title>Acknowledgements</title>{$x/*}</sec> as last into $x/preceding::body[1]),

for $x in $copy//*:abstract
return
(delete node $x,
insert node <sec>{$x/*}</sec> as first into $x/following::body[1])

)
return $copy

return file:write(concat($dir,$filename),$file2, map {'indent':'no'})

14 changes: 14 additions & 0 deletions batch-biorxiv-transform.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare namespace xlink="http://www.w3.org/1999/xlink";
declare namespace mml="http://www.w3.org/1998/Math/MathML";


declare variable $dir := '/Users/fredatherden/Desktop/biorxiv-tranformed/';
declare variable $xsl := doc('/Users/fredatherden/Documents/xsl/mixed-2-element-citation.xsl');



for $x in collection('biorxiv-xml')//*:article
let $filename := concat(substring-after($x//*:article-meta/*:article-id[@pub-id-type="doi"],'10.1101/'),'.xml')
let $file := xslt:transform($x, $xsl)
return file:write(concat($dir,$filename),$file, map {'indent':'no'})

8 changes: 8 additions & 0 deletions batch-normalise-test.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let $xsl := doc('/Users/fredatherden/Documents/xsl/normalise.xsl')

for $x in collection('ijm-xml')//*:article
let $t := xslt:transform($x,$xsl)
let $name := for $y in tokenize($x/base-uri(),'/')[last()]
return $y

return file:write(concat('/Users/fredatherden/Desktop/output/',$name),$t)
8 changes: 8 additions & 0 deletions batch-rdf-test.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let $xsl := doc('/Users/fredatherden/Documents/xsl/jats2rdf.xsl')

for $x in collection('ijm-xml')//*:article
let $t := xslt:transform($x,$xsl)
let $name := for $y in tokenize($x/base-uri(),'/')[last()]
return $y

return file:write(concat('/Users/fredatherden/Desktop/output/',$name),$t)
15 changes: 15 additions & 0 deletions batch-validate-test.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import module namespace schematron = "http://github.com/Schematron/schematron-basex";

declare variable $sch := schematron:compile(doc('/Users/fredatherden/Documents/GitHub/eLife-JATS-schematron/src/final-JATS-schematron.sch'));

for $x in collection('articles')//*:article[matches(descendant::*:article-id[@pub-id-type="publisher-id"],'^4222')]
let $article-id := $x//*:article-id[@pub-id-type="publisher-id"]/text()
let $folder := concat('/articles/elife-',$article-id,'-v')
let $v-no := number(substring-before(substring-after($x/base-uri(),$folder),'.xml'))
let $count := count(collection('articles')//*:article[descendant::*:article-id[@pub-id-type="publisher-id"]/text() = $article-id])
return if ($count != $v-no) then ()
else

let $svrl := schematron:validate($x, $sch)
return if ($svrl//*:successful-report[@id="unlinked-url-2"]) then $x/base-uri()
else ()
Loading

0 comments on commit 81f27ca

Please sign in to comment.