Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR 768 #768

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/preprint-changes.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,20 @@
|italic[bold[xref]]">
<xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
</xsl:template>

<!-- Strip or convert HTML <i> tags -->
<xsl:template xml:id="strip-i-tags" match="i">
<xsl:choose>
<xsl:when test="ancestor::italic">
<xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="italic">
<xsl:apply-templates select="*|text()|comment()|processing-instruction()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Strip unnecessary bolding and italicisation above citations -->
<xsl:template xml:id="strip-bold-italic-from-above-xref" match="bold[xref]|italic[xref]">
Expand Down
15 changes: 15 additions & 0 deletions src/rp-schematron-base.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,9 @@
<pattern id="abstracts">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<!-- The only elements you'd expect to be permitted in an impact statement -->
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="preceding::abstract[not(@abstract-type) and not(@xml:lang)] and not(@abstract-type) and not(@xml:lang)"
role="error"
id="abstract-test-1">There should only be one abstract without an abstract-type attribute (for the common-garden abstract) or xml:lang attirbute (for common-garden abstract in a language other than english). This asbtract does not have an abstract-type, but there is also a preceding abstract without an abstract-type or xml:lang. One of these needs to be given an abstract-type with the allowed values ('structured' for a syrctured abstract with sections; 'plain-language-summary' for a digest or author provided plain summary; 'teaser' for an impact statement; 'summary' for a general summary that's in addition to the common-garden abstract; 'graphical' for a graphical abstract).</report>
Expand All @@ -1515,6 +1518,18 @@
<report test="@abstract-type=$allowed-types and ./@abstract-type = preceding-sibling::abstract/@abstract-type"
role="warning"
id="abstract-test-6">abstract has the abstract-type '<value-of select="@abstract-type"/>', which is a permitted value, but it is not the only abstract with that type. It is very unlikely that two abstracts with the same abstract-type are required.</report>

<report test="@abstract-type='teaser' and descendant::*[not(name()=$impact-statement-elems)]"
role="error"
id="abstract-test-7">abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has the following descendant elements, which prove it needs a different type <value-of select="string-join(distinct-values(descendant::*[not(name()=$impact-statement-elems)]/name()),'; ')"/>.</report>

<report test="@abstract-type='teaser' and $word-count gt 60"
role="warning"
id="abstract-test-8">abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has greater than 60 words (<value-of select="$word-count"/>).</report>

<report test="@abstract-type='teaser' and count(p) gt 1"
role="error"
id="abstract-test-9">abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has <value-of select="count(p)"/> paragraphs (whereas an impact statement would have only one paragraph).</report>
</rule>

<rule context="abstract[parent::article-meta]/*" id="abstract-child-checks">
Expand Down
9 changes: 9 additions & 0 deletions src/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,9 @@

<pattern id="abstract-checks-pattern"><rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<!-- The only elements you'd expect to be permitted in an impact statement -->
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="preceding::abstract[not(@abstract-type) and not(@xml:lang)] and not(@abstract-type) and not(@xml:lang)" role="error" id="abstract-test-1">[abstract-test-1] There should only be one abstract without an abstract-type attribute (for the common-garden abstract) or xml:lang attirbute (for common-garden abstract in a language other than english). This asbtract does not have an abstract-type, but there is also a preceding abstract without an abstract-type or xml:lang. One of these needs to be given an abstract-type with the allowed values ('structured' for a syrctured abstract with sections; 'plain-language-summary' for a digest or author provided plain summary; 'teaser' for an impact statement; 'summary' for a general summary that's in addition to the common-garden abstract; 'graphical' for a graphical abstract).</report>

<report test="@abstract-type and not(@abstract-type=$allowed-types)" role="error" id="abstract-test-2">[abstract-test-2] abstract has an abstract-type (<value-of select="@abstract-type"/>), but it's not one of the permiited values: <value-of select="string-join($allowed-types,'; ')"/>.</report>
Expand All @@ -821,6 +824,12 @@
<report test="descendant::fig and not(@abstract-type='graphical')" role="error" id="abstract-test-5">[abstract-test-5] abstract has a descendant fig, but it does not have the attribute abstract-type="graphical". If it is a graphical abstract, it should have that type. If it's not a graphical abstract the content should be moved out of &lt;abstract&gt;</report>

<report test="@abstract-type=$allowed-types and ./@abstract-type = preceding-sibling::abstract/@abstract-type" role="warning" id="abstract-test-6">[abstract-test-6] abstract has the abstract-type '<value-of select="@abstract-type"/>', which is a permitted value, but it is not the only abstract with that type. It is very unlikely that two abstracts with the same abstract-type are required.</report>

<report test="@abstract-type='teaser' and descendant::*[not(name()=$impact-statement-elems)]" role="error" id="abstract-test-7">[abstract-test-7] abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has the following descendant elements, which prove it needs a different type <value-of select="string-join(distinct-values(descendant::*[not(name()=$impact-statement-elems)]/name()),'; ')"/>.</report>

<report test="@abstract-type='teaser' and $word-count gt 60" role="warning" id="abstract-test-8">[abstract-test-8] abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has greater than 60 words (<value-of select="$word-count"/>).</report>

<report test="@abstract-type='teaser' and count(p) gt 1" role="error" id="abstract-test-9">[abstract-test-9] abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has <value-of select="count(p)"/> paragraphs (whereas an impact statement would have only one paragraph).</report>
</rule></pattern><pattern id="abstract-child-checks-pattern"><rule context="abstract[parent::article-meta]/*" id="abstract-child-checks">
<let name="allowed-children" value="('label','title','sec','p','fig','list')"/>
<assert test="name()=$allowed-children" role="error" id="abstract-child-test-1">[abstract-child-test-1] <name/> is not permitted within abstract.</assert>
Expand Down
41 changes: 41 additions & 0 deletions src/rp-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -5802,6 +5802,8 @@
<!--RULE abstract-checks-->
<xsl:template match="abstract[parent::article-meta]" priority="1000" mode="M98">
<xsl:variable name="allowed-types" select="('structured','plain-language-summary','teaser','summary','graphical')"/>
<xsl:variable name="impact-statement-elems" select="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<xsl:variable name="word-count" select="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<!--REPORT error-->
<xsl:if test="preceding::abstract[not(@abstract-type) and not(@xml:lang)] and not(@abstract-type) and not(@xml:lang)">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="preceding::abstract[not(@abstract-type) and not(@xml:lang)] and not(@abstract-type) and not(@xml:lang)">
Expand Down Expand Up @@ -5878,6 +5880,45 @@
<xsl:text/>', which is a permitted value, but it is not the only abstract with that type. It is very unlikely that two abstracts with the same abstract-type are required.</svrl:text>
</svrl:successful-report>
</xsl:if>
<!--REPORT error-->
<xsl:if test="@abstract-type='teaser' and descendant::*[not(name()=$impact-statement-elems)]">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="@abstract-type='teaser' and descendant::*[not(name()=$impact-statement-elems)]">
<xsl:attribute name="id">abstract-test-7</xsl:attribute>
<xsl:attribute name="role">error</xsl:attribute>
<xsl:attribute name="location">
<xsl:apply-templates select="." mode="schematron-select-full-path"/>
</xsl:attribute>
<svrl:text>[abstract-test-7] abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has the following descendant elements, which prove it needs a different type <xsl:text/>
<xsl:value-of select="string-join(distinct-values(descendant::*[not(name()=$impact-statement-elems)]/name()),'; ')"/>
<xsl:text/>.</svrl:text>
</svrl:successful-report>
</xsl:if>
<!--REPORT warning-->
<xsl:if test="@abstract-type='teaser' and $word-count gt 60">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="@abstract-type='teaser' and $word-count gt 60">
<xsl:attribute name="id">abstract-test-8</xsl:attribute>
<xsl:attribute name="role">warning</xsl:attribute>
<xsl:attribute name="location">
<xsl:apply-templates select="." mode="schematron-select-full-path"/>
</xsl:attribute>
<svrl:text>[abstract-test-8] abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has greater than 60 words (<xsl:text/>
<xsl:value-of select="$word-count"/>
<xsl:text/>).</svrl:text>
</svrl:successful-report>
</xsl:if>
<!--REPORT error-->
<xsl:if test="@abstract-type='teaser' and count(p) gt 1">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="@abstract-type='teaser' and count(p) gt 1">
<xsl:attribute name="id">abstract-test-9</xsl:attribute>
<xsl:attribute name="role">error</xsl:attribute>
<xsl:attribute name="location">
<xsl:apply-templates select="." mode="schematron-select-full-path"/>
</xsl:attribute>
<svrl:text>[abstract-test-9] abstract has the abstract-type 'teaser', meaning it is equivalent to an impact statement, but it has <xsl:text/>
<xsl:value-of select="count(p)"/>
<xsl:text/> paragraphs (whereas an impact statement would have only one paragraph).</svrl:text>
</svrl:successful-report>
</xsl:if>
<xsl:apply-templates select="*" mode="M98"/>
</xsl:template>
<xsl:template match="text()" priority="-1" mode="M98"/>
Expand Down
2 changes: 2 additions & 0 deletions test/tests/preprint-changes/all/input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
</sec>
<sec id="s3">
<title>MATERIALS &amp; METHODS</title>
<p><italic><bold><i>some text</i></bold></italic></p>
<p><i>ital<bold>ics</bold></i></p>
</sec>
</body>
<back>
Expand Down
2 changes: 2 additions & 0 deletions test/tests/preprint-changes/all/output.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
</sec>
<sec id="s3">
<title>Materials &amp; methods</title>
<p><italic><bold>some text</bold></italic></p>
<p><italic>ital<bold>ics</bold></italic></p>
</sec>
</body>
<back>
Expand Down
5 changes: 5 additions & 0 deletions test/tests/preprint-changes/strip-i-tags/input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--Testing template with id: strip-i-tags-->
<sec id="s3">
<p><italic><bold><i>some text</i></bold></italic></p>
<p><i>ital<bold>ics</bold></i></p>
</sec>
5 changes: 5 additions & 0 deletions test/tests/preprint-changes/strip-i-tags/output.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--Testing template with id: strip-i-tags-->
<sec id="s3">
<p><italic><bold>some text</bold></italic></p>
<p><italic>ital<bold>ics</bold></italic></p>
</sec>
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<pattern id="abstract-checks-pattern">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="preceding::abstract[not(@abstract-type) and not(@xml:lang)] and not(@abstract-type) and not(@xml:lang)" role="error" id="abstract-test-1">[abstract-test-1] There should only be one abstract without an abstract-type attribute (for the common-garden abstract) or xml:lang attirbute (for common-garden abstract in a language other than english). This asbtract does not have an abstract-type, but there is also a preceding abstract without an abstract-type or xml:lang. One of these needs to be given an abstract-type with the allowed values ('structured' for a syrctured abstract with sections; 'plain-language-summary' for a digest or author provided plain summary; 'teaser' for an impact statement; 'summary' for a general summary that's in addition to the common-garden abstract; 'graphical' for a graphical abstract).</report>
</rule>
</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<pattern id="abstract-checks-pattern">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="@abstract-type and not(@abstract-type=$allowed-types)" role="error" id="abstract-test-2">[abstract-test-2] abstract has an abstract-type (<value-of select="@abstract-type"/>), but it's not one of the permiited values: <value-of select="string-join($allowed-types,'; ')"/>.</report>
</rule>
</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<pattern id="abstract-checks-pattern">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="matches(lower-case(title[1]),'funding')" role="error" id="abstract-test-3">[abstract-test-3] abstract has a title that indicates it contains funding information (<value-of select="title[1]"/>) If this is funding information, it should be captured as a section in back or as part of an (if existing) structured abstract.</report>
</rule>
</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<pattern id="abstract-checks-pattern">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="matches(lower-case(title[1]),'data')" role="error" id="abstract-test-4">[abstract-test-4] abstract has a title that indicates it contains a data availability statement (<value-of select="title[1]"/>) If this is a data availability statement, it should be captured as a section in back.</report>
</rule>
</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<pattern id="abstract-checks-pattern">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="descendant::fig and not(@abstract-type='graphical')" role="error" id="abstract-test-5">[abstract-test-5] abstract has a descendant fig, but it does not have the attribute abstract-type="graphical". If it is a graphical abstract, it should have that type. If it's not a graphical abstract the content should be moved out of &lt;abstract&gt;</report>
</rule>
</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
<pattern id="abstract-checks-pattern">
<rule context="abstract[parent::article-meta]" id="abstract-checks">
<let name="allowed-types" value="('structured','plain-language-summary','teaser','summary','graphical')"/>
<let name="impact-statement-elems" value="('title','p','italic','bold','sup','sub','sc','monospace','xref')"/>
<let name="word-count" value="count(for $x in tokenize(normalize-space(replace(.,'\p{P}','')),' ') return $x)"/>
<report test="@abstract-type=$allowed-types and ./@abstract-type = preceding-sibling::abstract/@abstract-type" role="warning" id="abstract-test-6">[abstract-test-6] abstract has the abstract-type '<value-of select="@abstract-type"/>', which is a permitted value, but it is not the only abstract with that type. It is very unlikely that two abstracts with the same abstract-type are required.</report>
</rule>
</pattern>
Expand Down
Loading
Loading