Skip to content

Commit

Permalink
Merge pull request #749 from elifesciences/pr-749
Browse files Browse the repository at this point in the history
RP - check rp version against preprint version
  • Loading branch information
fred-atherden authored Nov 18, 2024
2 parents 01c5d19 + f7e3f3b commit 6bc7947
Show file tree
Hide file tree
Showing 8 changed files with 566 additions and 294 deletions.
9 changes: 9 additions & 0 deletions src/rp-schematron-base.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,15 @@
role="error"
id="article-version-10">article-version-alternatives must contain a &lt;article-version article-version-type="publication-state">.</assert>
</rule>

<rule context="article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]" id="rp-and-preprint-version-checks">
<let name="preprint-version" value="number(substring-after(descendant::article-version[@article-version-type='preprint-version'][1],'.'))"/>
<let name="rp-version" value="number(replace(article-id[@specific-use='version'][1],'^.*\.',''))"/>

<assert test="$rp-version le $preprint-version"
role="error"
id="article-version-12">This is Reviewed Preprint version <value-of select="$rp-version"/>, but according to the article-version, it's based on preprint version <value-of select="$preprint-version"/>. This cannot be correct.</assert>
</rule>

<rule context="article/front/article-meta/pub-date[@pub-type='epub']/year" id="preprint-pub-checks">
<assert test=".=('2024','2025')"
Expand Down
5 changes: 5 additions & 0 deletions src/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@
<assert test="article-version[@article-version-type='preprint-version']" role="error" id="article-version-9">[article-version-9] article-version-alternatives must contain a &lt;article-version article-version-type="preprint-version"&gt;.</assert>

<assert test="article-version[@article-version-type='publication-state']" role="error" id="article-version-10">[article-version-10] article-version-alternatives must contain a &lt;article-version article-version-type="publication-state"&gt;.</assert>
</rule></pattern><pattern id="rp-and-preprint-version-checks-pattern"><rule context="article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]" id="rp-and-preprint-version-checks">
<let name="preprint-version" value="number(substring-after(descendant::article-version[@article-version-type='preprint-version'][1],'.'))"/>
<let name="rp-version" value="number(replace(article-id[@specific-use='version'][1],'^.*\.',''))"/>

<assert test="$rp-version le $preprint-version" role="error" id="article-version-12">[article-version-12] This is Reviewed Preprint version <value-of select="$rp-version"/>, but according to the article-version, it's based on preprint version <value-of select="$preprint-version"/>. This cannot be correct.</assert>
</rule></pattern><pattern id="preprint-pub-checks-pattern"><rule context="article/front/article-meta/pub-date[@pub-type='epub']/year" id="preprint-pub-checks">
<assert test=".=('2024','2025')" role="warning" id="preprint-pub-date-1">[preprint-pub-date-1] This preprint version was posted in <value-of select="."/>. Is it the correct version that corresponds to the version submitted to eLife?</assert>
</rule></pattern><pattern id="contrib-checks-pattern"><rule context="article/front/article-meta/contrib-group/contrib" id="contrib-checks">
Expand Down
626 changes: 332 additions & 294 deletions src/rp-schematron.xsl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron" xmlns:meca="http://manuscriptexchange.org" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:ali="http://www.niso.org/schemas/ali/1.0/" xmlns:file="java.io.File" xmlns:java="http://www.java.com/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" queryBinding="xslt2">
<title>eLife reviewed preprint schematron</title>
<ns uri="http://www.niso.org/schemas/ali/1.0/" prefix="ali"/>
<ns uri="http://www.w3.org/XML/1998/namespace" prefix="xml"/>
<ns uri="http://www.w3.org/1999/xlink" prefix="xlink"/>
<ns uri="http://www.w3.org/2001/XInclude" prefix="xi"/>
<ns uri="http://www.w3.org/1998/Math/MathML" prefix="mml"/>
<ns uri="http://saxon.sf.net/" prefix="saxon"/>
<ns uri="http://purl.org/dc/terms/" prefix="dc"/>
<ns uri="http://www.w3.org/2001/XMLSchema" prefix="xs"/>
<ns uri="https://elifesciences.org/namespace" prefix="e"/>
<ns uri="java.io.File" prefix="file"/>
<ns uri="http://www.java.com/" prefix="java"/>
<ns uri="http://manuscriptexchange.org" prefix="meca"/>
<xsl:function name="e:isbn-sum" as="xs:integer">
<xsl:param name="s" as="xs:string"/>
<xsl:choose>
<xsl:when test="string-length($s) = 10">
<xsl:variable name="d1" select="number(substring($s,1,1)) * 10"/>
<xsl:variable name="d2" select="number(substring($s,2,1)) * 9"/>
<xsl:variable name="d3" select="number(substring($s,3,1)) * 8"/>
<xsl:variable name="d4" select="number(substring($s,4,1)) * 7"/>
<xsl:variable name="d5" select="number(substring($s,5,1)) * 6"/>
<xsl:variable name="d6" select="number(substring($s,6,1)) * 5"/>
<xsl:variable name="d7" select="number(substring($s,7,1)) * 4"/>
<xsl:variable name="d8" select="number(substring($s,8,1)) * 3"/>
<xsl:variable name="d9" select="number(substring($s,9,1)) * 2"/>
<xsl:variable name="d10" select="number(substring($s,10,1)) * 1"/>
<xsl:value-of select="number($d1 + $d2 + $d3 + $d4 + $d5 + $d6 + $d7 + $d8 + $d9 + $d10) mod 11"/>
</xsl:when>
<xsl:when test="string-length($s) = 13">
<xsl:variable name="d1" select="number(substring($s,1,1))"/>
<xsl:variable name="d2" select="number(substring($s,2,1)) * 3"/>
<xsl:variable name="d3" select="number(substring($s,3,1))"/>
<xsl:variable name="d4" select="number(substring($s,4,1)) * 3"/>
<xsl:variable name="d5" select="number(substring($s,5,1))"/>
<xsl:variable name="d6" select="number(substring($s,6,1)) * 3"/>
<xsl:variable name="d7" select="number(substring($s,7,1))"/>
<xsl:variable name="d8" select="number(substring($s,8,1)) * 3"/>
<xsl:variable name="d9" select="number(substring($s,9,1))"/>
<xsl:variable name="d10" select="number(substring($s,10,1)) * 3"/>
<xsl:variable name="d11" select="number(substring($s,11,1))"/>
<xsl:variable name="d12" select="number(substring($s,12,1)) * 3"/>
<xsl:variable name="d13" select="number(substring($s,13,1))"/>
<xsl:value-of select="number($d1 + $d2 + $d3 + $d4 + $d5 + $d6 + $d7 + $d8 + $d9 + $d10 + $d11 + $d12 + $d13) mod 10"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number('1')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="e:is-valid-issn" as="xs:boolean">
<xsl:param name="s" as="xs:string"/>
<xsl:choose>
<xsl:when test="not(matches($s,'^\d{4}\-\d{3}[\dX]$'))">
<xsl:value-of select="false()"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="d1" select="number(substring($s,1,1)) * 8"/>
<xsl:variable name="d2" select="number(substring($s,2,1)) * 7"/>
<xsl:variable name="d3" select="number(substring($s,3,1)) * 6"/>
<xsl:variable name="d4" select="number(substring($s,4,1)) * 5"/>
<xsl:variable name="d5" select="number(substring($s,6,1)) * 4"/>
<xsl:variable name="d6" select="number(substring($s,7,1)) * 3"/>
<xsl:variable name="d7" select="number(substring($s,8,1)) * 2"/>
<xsl:variable name="remainder" select="number($d1 + $d2 + $d3 + $d4 + $d5 + $d6 + $d7) mod 11"/>
<xsl:variable name="calc" select="if ($remainder=0) then 0 else (11 - $remainder)"/>
<xsl:variable name="check" select="if (substring($s,9,1)='X') then 10 else number(substring($s,9,1))"/>
<xsl:value-of select="$calc = $check"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="e:get-name" as="xs:string">
<xsl:param name="name"/>
<xsl:choose>
<xsl:when test="$name/given-names[1] and $name/surname[1] and $name/suffix[1]">
<xsl:value-of select="concat($name/given-names[1],' ',$name/surname[1],' ',$name/suffix[1])"/>
</xsl:when>
<xsl:when test="not($name/given-names[1]) and $name/surname[1] and $name/suffix[1]">
<xsl:value-of select="concat($name/surname[1],' ',$name/suffix[1])"/>
</xsl:when>
<xsl:when test="$name/given-names[1] and $name/surname[1] and not($name/suffix[1])">
<xsl:value-of select="concat($name/given-names[1],' ',$name/surname[1])"/>
</xsl:when>
<xsl:when test="not($name/given-names[1]) and $name/surname[1] and not($name/suffix[1])">
<xsl:value-of select="$name/surname[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'No elements present'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="e:get-copyright-holder">
<xsl:param name="contrib-group"/>
<xsl:variable name="author-count" select="count($contrib-group/contrib[@contrib-type='author'])"/>
<xsl:choose>
<xsl:when test="$author-count lt 1"/>
<xsl:when test="$author-count = 1">
<xsl:choose>
<xsl:when test="$contrib-group/contrib[@contrib-type='author']/collab">
<xsl:value-of select="$contrib-group/contrib[@contrib-type='author']/collab[1]/text()[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$contrib-group/contrib[@contrib-type='author']/name[1]/surname[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$author-count = 2">
<xsl:choose>
<xsl:when test="$contrib-group/contrib[@contrib-type='author']/collab">
<xsl:choose>
<xsl:when test="$contrib-group/contrib[@contrib-type='author'][1]/collab and $contrib-group/contrib[@contrib-type='author'][2]/collab">
<xsl:value-of select="concat($contrib-group/contrib[@contrib-type='author']/collab[1]/text()[1],' &amp; ',$contrib-group/contrib[@contrib-type='author']/collab[2]/text()[1])"/>
</xsl:when>
<xsl:when test="$contrib-group/contrib[@contrib-type='author'][1]/collab">
<xsl:value-of select="concat($contrib-group/contrib[@contrib-type='author'][1]/collab[1]/text()[1],' &amp; ',$contrib-group/contrib[@contrib-type='author'][2]/name[1]/surname[1])"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($contrib-group/contrib[@contrib-type='author'][1]/name[1]/surname[1],' &amp; ',$contrib-group/contrib[@contrib-type='author'][2]/collab[1]/text()[1])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($contrib-group/contrib[@contrib-type='author'][1]/name[1]/surname[1],' &amp; ',$contrib-group/contrib[@contrib-type='author'][2]/name[1]/surname[1])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>

<xsl:otherwise>
<xsl:variable name="is-equal-contrib" select="if ($contrib-group/contrib[@contrib-type='author'][1]/@equal-contrib='yes') then true() else false()"/>

<xsl:value-of select="concat(e:get-surname($contrib-group/contrib[@contrib-type='author'][1]),' et al')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="e:get-surname" as="text()">
<xsl:param name="contrib"/>
<xsl:choose>
<xsl:when test="$contrib/collab">
<xsl:value-of select="$contrib/collab[1]/text()[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$contrib//name[1]/surname[1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<pattern id="rp-and-preprint-version-checks-pattern">
<rule context="article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]" id="rp-and-preprint-version-checks">
<let name="preprint-version" value="number(substring-after(descendant::article-version[@article-version-type='preprint-version'][1],'.'))"/>
<let name="rp-version" value="number(replace(article-id[@specific-use='version'][1],'^.*\.',''))"/>
<assert test="$rp-version le $preprint-version" role="error" id="article-version-12">[article-version-12] This is Reviewed Preprint version <value-of select="$rp-version"/>, but according to the article-version, it's based on preprint version <value-of select="$preprint-version"/>. This cannot be correct.</assert>
</rule>
</pattern>
<pattern id="root-pattern">
<rule context="root" id="root-rule">
<assert test="descendant::article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]" role="error" id="rp-and-preprint-version-checks-xspec-assert">article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')] must be present.</assert>
</rule>
</pattern>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?oxygen SCHSchema="article-version-12.sch"?>
<!--Context: article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]
Test: assert $rp-version le $preprint-version
Message: This is Reviewed Preprint version , but according to the article-version, it's based on preprint version . This cannot be correct. -->
<root xmlns:ali="http://www.niso.org/schemas/ali/1.0/" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<article>
<front>
<journal-meta>
<journal-id journal-id-type="nlm-ta">elife</journal-id>
</journal-meta>
<article-meta>
<article-id pub-id-type="doi" specific-use="version">10.7554/eLife.1234321.2</article-id>
<article-version-alternatives>
<article-version article-version-type="publication-state">reviewed preprint</article-version>
<article-version article-version-type="preprint-version">1.1</article-version>
</article-version-alternatives>
</article-meta>
</front>
</article>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?oxygen SCHSchema="article-version-12.sch"?>
<!--Context: article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]
Test: assert $rp-version le $preprint-version
Message: This is Reviewed Preprint version , but according to the article-version, it's based on preprint version . This cannot be correct. -->
<root xmlns:ali="http://www.niso.org/schemas/ali/1.0/" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<article>
<front>
<journal-meta>
<journal-id journal-id-type="nlm-ta">elife</journal-id>
</journal-meta>
<article-meta>
<article-id pub-id-type="doi" specific-use="version">10.7554/eLife.1234321.2</article-id>
<article-version-alternatives>
<article-version article-version-type="publication-state">reviewed preprint</article-version>
<article-version article-version-type="preprint-version">1.2</article-version>
</article-version-alternatives>
</article-meta>
</front>
</article>
</root>
9 changes: 9 additions & 0 deletions test/xspec/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,14 @@
<assert test="article-version[@article-version-type='publication-state']" role="error" id="article-version-10">article-version-alternatives must contain a &lt;article-version article-version-type="publication-state"&gt;.</assert>
</rule>
</pattern>
<pattern id="rp-and-preprint-version-checks-pattern">
<rule context="article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]" id="rp-and-preprint-version-checks">
<let name="preprint-version" value="number(substring-after(descendant::article-version[@article-version-type='preprint-version'][1],'.'))"/>
<let name="rp-version" value="number(replace(article-id[@specific-use='version'][1],'^.*\.',''))"/>

<assert test="$rp-version le $preprint-version" role="error" id="article-version-12">This is Reviewed Preprint version <value-of select="$rp-version"/>, but according to the article-version, it's based on preprint version <value-of select="$preprint-version"/>. This cannot be correct.</assert>
</rule>
</pattern>
<pattern id="preprint-pub-checks-pattern">
<rule context="article/front/article-meta/pub-date[@pub-type='epub']/year" id="preprint-pub-checks">
<assert test=".=('2024','2025')" role="warning" id="preprint-pub-date-1">This preprint version was posted in <value-of select="."/>. Is it the correct version that corresponds to the version submitted to eLife?</assert>
Expand Down Expand Up @@ -1512,6 +1520,7 @@
<assert test="descendant::article/front/article-meta/author-notes/fn" role="error" id="author-notes-fn-checks-xspec-assert">article/front/article-meta/author-notes/fn must be present.</assert>
<assert test="descendant::article/front/article-meta//article-version" role="error" id="article-version-checks-xspec-assert">article/front/article-meta//article-version must be present.</assert>
<assert test="descendant::article/front/article-meta/article-version-alternatives" role="error" id="article-version-alternatives-checks-xspec-assert">article/front/article-meta/article-version-alternatives must be present.</assert>
<assert test="descendant::article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')]" role="error" id="rp-and-preprint-version-checks-xspec-assert">article/front[journal-meta/journal-id='elife']/article-meta[matches(replace(article-id[@specific-use='version'][1],'^.*\.',''),'^\d\d?$') and matches(descendant::article-version[@article-version-type='preprint-version'][1],'^1\.\d+$')] must be present.</assert>
<assert test="descendant::article/front/article-meta/pub-date[@pub-type='epub']/year" role="error" id="preprint-pub-checks-xspec-assert">article/front/article-meta/pub-date[@pub-type='epub']/year must be present.</assert>
<assert test="descendant::article/front/article-meta/contrib-group/contrib" role="error" id="contrib-checks-xspec-assert">article/front/article-meta/contrib-group/contrib must be present.</assert>
<assert test="descendant::front[journal-meta/lower-case(journal-id[1])='elife']/article-meta/volume" role="error" id="volume-test-xspec-assert">front[journal-meta/lower-case(journal-id[1])='elife']/article-meta/volume must be present.</assert>
Expand Down
Loading

0 comments on commit 6bc7947

Please sign in to comment.