Skip to content

Commit

Permalink
Add check for paragraphs only containing inline graphic(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Feb 20, 2024
1 parent 366aef5 commit 1a7fa30
Show file tree
Hide file tree
Showing 14 changed files with 2,709 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/final-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,9 @@

<assert test="count($text-tokens) = 0" role="error" id="p-test-3">[p-test-3] p element contains <value-of select="string-join($text-tokens,', ')"/> - The spacing is incorrect.</assert>



<report test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''" role="error" id="final-p-test-8">[final-p-test-8] p element contains one or more inline-graphics and no other text, which is not permitted.</report>
</rule></pattern><pattern id="p-child-tests-pattern"><rule context="article//p/*" id="p-child-tests">
<let name="allowed-p-blocks" value="('bold', 'sup', 'sub', 'sc', 'italic', 'underline', 'xref','inline-formula', 'disp-formula','supplementary-material', 'code', 'ext-link', 'named-content', 'inline-graphic', 'monospace', 'related-object', 'table-wrap','styled-content')"/>

Expand Down
12 changes: 12 additions & 0 deletions src/final-JATS-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13521,6 +13521,18 @@
</svrl:failed-assert>
</xsl:otherwise>
</xsl:choose>

<!--REPORT error-->
<xsl:if test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''">
<xsl:attribute name="id">final-p-test-8</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>[final-p-test-8] p element contains one or more inline-graphics and no other text, which is not permitted.</svrl:text>
</svrl:successful-report>
</xsl:if>
<xsl:apply-templates select="*" mode="M174"/>
</xsl:template>
<xsl:template match="text()" priority="-1" mode="M174"/>
Expand Down
3 changes: 3 additions & 0 deletions src/final-package-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,9 @@

<assert test="count($text-tokens) = 0" role="error" id="p-test-3">p element contains <value-of select="string-join($text-tokens,', ')"/> - The spacing is incorrect.</assert>



<report test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''" role="error" id="final-p-test-8">p element contains one or more inline-graphics and no other text, which is not permitted.</report>
</rule></pattern><pattern id="p-child-tests-pattern"><rule context="article//p/*" id="p-child-tests">
<let name="allowed-p-blocks" value="('bold', 'sup', 'sub', 'sc', 'italic', 'underline', 'xref','inline-formula', 'disp-formula','supplementary-material', 'code', 'ext-link', 'named-content', 'inline-graphic', 'monospace', 'related-object', 'table-wrap','styled-content')"/>

Expand Down
3 changes: 3 additions & 0 deletions src/pre-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2463,6 +2463,9 @@

<assert test="count($text-tokens) = 0" role="error" id="p-test-3">[p-test-3] p element contains <value-of select="string-join($text-tokens,', ')"/> - The spacing is incorrect.</assert>

<report test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''" role="warning" id="pre-p-test-8">[pre-p-test-8] p element contains one or more inline-graphics and no other text, which is not permitted. Are the image(s) equations or content that should otherwise be captured in a machine readable way?</report>


</rule></pattern><pattern id="p-child-tests-pattern"><rule context="article//p/*" id="p-child-tests">
<let name="allowed-p-blocks" value="('bold', 'sup', 'sub', 'sc', 'italic', 'underline', 'xref','inline-formula', 'disp-formula','supplementary-material', 'code', 'ext-link', 'named-content', 'inline-graphic', 'monospace', 'related-object', 'table-wrap','styled-content')"/>

Expand Down
12 changes: 12 additions & 0 deletions src/pre-JATS-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13406,6 +13406,18 @@
</svrl:failed-assert>
</xsl:otherwise>
</xsl:choose>

<!--REPORT warning-->
<xsl:if test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''">
<xsl:attribute name="id">pre-p-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>[pre-p-test-8] p element contains one or more inline-graphics and no other text, which is not permitted. Are the image(s) equations or content that should otherwise be captured in a machine readable way?</svrl:text>
</svrl:successful-report>
</xsl:if>
<xsl:apply-templates select="*" mode="M172"/>
</xsl:template>
<xsl:template match="text()" priority="-1" mode="M172"/>
Expand Down
7 changes: 7 additions & 0 deletions src/schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -3801,6 +3801,13 @@
role="error"
id="p-test-3">p element contains <value-of select="string-join($text-tokens,', ')"/> - The spacing is incorrect.</assert>

<report test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''"
role="warning"
id="pre-p-test-8">p element contains one or more inline-graphics and no other text, which is not permitted. Are the image(s) equations or content that should otherwise be captured in a machine readable way?</report>

<report test="(count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''"
role="error"
id="final-p-test-8">p element contains one or more inline-graphics and no other text, which is not permitted.</report>
</rule>


Expand Down
11 changes: 11 additions & 0 deletions test/tests/gen/p-text-tests/final-p-test-8/fail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?oxygen SCHSchema="final-p-test-8.sch"?>
<!--Context: p[not(inline-formula or disp-formula or code)]
Test: report (count(descendant::*:inline-graphic) ge 1) and normalize-space(.)=''
Message: p element contains one or more inline-graphics and no other text, which is not permitted. -->
<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>
<p>
<inline-graphic/>
</p>
</article>
</root>
Loading

0 comments on commit 1a7fa30

Please sign in to comment.