Skip to content

Commit

Permalink
Add ext-link check
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Feb 14, 2024
1 parent f361add commit ca65caa
Show file tree
Hide file tree
Showing 11 changed files with 1,374 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/final-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,8 @@
<report see="https://elifeproduction.slab.com/posts/data-availability-qi8vg0qp#ext-link-child-test-5" test="contains(@xlink:href,'datadryad.org/review?')" role="warning" id="ext-link-child-test-5">[ext-link-child-test-5] ext-link looks like it points to a review dryad dataset - <value-of select="."/>. Should it be updated?</report>

<report see="https://elifeproduction.slab.com/posts/general-layout-and-formatting-wq0m31at#hyyhg-ext-link-text" test="(.!=@xlink:href) and matches(.,'https?:|ftp:|www\.')" role="warning" id="ext-link-text">[ext-link-text] The text for a URL is '<value-of select="."/>' (which looks like a URL), but it is not the same as the actual embedded link, which is '<value-of select="@xlink:href"/>'.</report>

<report test="contains(lower-case(@xlink:href),'kriyadocs.com')" role="error" id="kriya-ext-link">[kriya-ext-link] URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - <value-of select="@xlink:href"/>.</report>
</rule></pattern><pattern id="software-heritage-tests-pattern"><rule context="ref/element-citation[ext-link[1][contains(@xlink:href,'softwareheritage')]]" id="software-heritage-tests">
<let name="version" value="replace(substring-after(ext-link[1]/@xlink:href,'anchor='),'/$','')"/>

Expand Down
14 changes: 14 additions & 0 deletions src/final-JATS-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -14043,6 +14043,20 @@
<xsl:text/>'.</svrl:text>
</svrl:successful-report>
</xsl:if>

<!--REPORT error-->
<xsl:if test="contains(lower-case(@xlink:href),'kriyadocs.com')">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="contains(lower-case(@xlink:href),'kriyadocs.com')">
<xsl:attribute name="id">kriya-ext-link</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>[kriya-ext-link] URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - <xsl:text/>
<xsl:value-of select="@xlink:href"/>
<xsl:text/>.</svrl:text>
</svrl:successful-report>
</xsl:if>
<xsl:apply-templates select="*" mode="M178"/>
</xsl:template>
<xsl:template match="text()" priority="-1" mode="M178"/>
Expand Down
2 changes: 2 additions & 0 deletions src/final-package-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2601,6 +2601,8 @@
<report see="https://elifeproduction.slab.com/posts/data-availability-qi8vg0qp#ext-link-child-test-5" test="contains(@xlink:href,'datadryad.org/review?')" role="warning" id="ext-link-child-test-5">ext-link looks like it points to a review dryad dataset - <value-of select="."/>. Should it be updated?</report>

<report see="https://elifeproduction.slab.com/posts/general-layout-and-formatting-wq0m31at#hyyhg-ext-link-text" test="(.!=@xlink:href) and matches(.,'https?:|ftp:|www\.')" role="warning" id="ext-link-text">The text for a URL is '<value-of select="."/>' (which looks like a URL), but it is not the same as the actual embedded link, which is '<value-of select="@xlink:href"/>'.</report>

<report test="contains(lower-case(@xlink:href),'kriyadocs.com')" role="error" id="kriya-ext-link">URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - <value-of select="@xlink:href"/>.</report>
</rule></pattern><pattern id="software-heritage-tests-pattern"><rule context="ref/element-citation[ext-link[1][contains(@xlink:href,'softwareheritage')]]" id="software-heritage-tests">
<let name="version" value="replace(substring-after(ext-link[1]/@xlink:href,'anchor='),'/$','')"/>

Expand Down
2 changes: 2 additions & 0 deletions src/pre-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,8 @@
<report see="https://elifeproduction.slab.com/posts/data-availability-qi8vg0qp#ext-link-child-test-5" test="contains(@xlink:href,'datadryad.org/review?')" role="warning" id="ext-link-child-test-5">[ext-link-child-test-5] ext-link looks like it points to a review dryad dataset - <value-of select="."/>. Should it be updated?</report>

<report see="https://elifeproduction.slab.com/posts/general-layout-and-formatting-wq0m31at#hyyhg-ext-link-text" test="(.!=@xlink:href) and matches(.,'https?:|ftp:|www\.')" role="warning" id="ext-link-text">[ext-link-text] The text for a URL is '<value-of select="."/>' (which looks like a URL), but it is not the same as the actual embedded link, which is '<value-of select="@xlink:href"/>'.</report>

<report test="contains(lower-case(@xlink:href),'kriyadocs.com')" role="error" id="kriya-ext-link">[kriya-ext-link] URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - <value-of select="@xlink:href"/>.</report>
</rule></pattern><pattern id="software-heritage-tests-pattern"><rule context="ref/element-citation[ext-link[1][contains(@xlink:href,'softwareheritage')]]" id="software-heritage-tests">
<let name="version" value="replace(substring-after(ext-link[1]/@xlink:href,'anchor='),'/$','')"/>

Expand Down
14 changes: 14 additions & 0 deletions src/pre-JATS-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13928,6 +13928,20 @@
<xsl:text/>'.</svrl:text>
</svrl:successful-report>
</xsl:if>

<!--REPORT error-->
<xsl:if test="contains(lower-case(@xlink:href),'kriyadocs.com')">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="contains(lower-case(@xlink:href),'kriyadocs.com')">
<xsl:attribute name="id">kriya-ext-link</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>[kriya-ext-link] URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - <xsl:text/>
<xsl:value-of select="@xlink:href"/>
<xsl:text/>.</svrl:text>
</svrl:successful-report>
</xsl:if>
<xsl:apply-templates select="*" mode="M176"/>
</xsl:template>
<xsl:template match="text()" priority="-1" mode="M176"/>
Expand Down
4 changes: 4 additions & 0 deletions src/schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -3971,6 +3971,10 @@ else self::*/local-name() = $allowed-p-blocks"
test="(.!=@xlink:href) and matches(.,'https?:|ftp:|www\.')"
role="warning"
id="ext-link-text">The text for a URL is '<value-of select="."/>' (which looks like a URL), but it is not the same as the actual embedded link, which is '<value-of select="@xlink:href"/>'.</report>

<report test="contains(lower-case(@xlink:href),'kriyadocs.com')"
role="error"
id="kriya-ext-link">URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - <value-of select="@xlink:href"/>.</report>
</rule>

<rule context="ref/element-citation[ext-link[1][contains(@xlink:href,'softwareheritage')]]"
Expand Down
9 changes: 9 additions & 0 deletions test/tests/gen/ext-link-tests/kriya-ext-link/fail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?oxygen SCHSchema="kriya-ext-link.sch"?>
<!--Context: ext-link[@ext-link-type='uri']
Test: report contains(lower-case(@xlink:href),'kriyadocs.com')
Message: URL contains 'kriyadocs.com', so it looks like a link to kriya which must be incorrect - . -->
<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>
<ext-link ext-link-type="uri" xlink:href="https://resources.kriyadocs.com/resources/elife/elife/87895/resources/eabc1e01-1537-4a0a-9e0a-794544bb01c6.html#Sx2">test</ext-link>
</article>
</root>
Loading

0 comments on commit ca65caa

Please sign in to comment.