Skip to content

Commit

Permalink
use string equality in lang checks
Browse files Browse the repository at this point in the history
`exists()` will not work as the variable already makes use of `string-join()` (to account for languages with multiple descriptions)
  • Loading branch information
fred-atherden committed Nov 21, 2024
1 parent d43c111 commit 0c04de8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/rp-schematron-base.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,11 @@
<let name="xml-lang-value" value="@xml:lang"/>
<let name="languages" value="'languages.xml'"/>
<let name="subtag-description" value="string-join(document($languages)//*:item[@subtag=$xml-lang-value]/*:description,' / ')"/>
<assert test="exists($subtag-description)"
<assert test="$subtag-description!=''"
role="error"
id="abstract-lang-test-1">The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>

<report test="exists($subtag-description)"
<report test="$subtag-description!=''"
role="warning"
id="abstract-lang-test-2"><name/> has an xml:lang attribute with the value '<value-of select="$xml-lang-value"/>', which corresponds to the following language: <value-of select="$subtag-description"/>. Please check this is correct.</report>
</rule>
Expand Down
4 changes: 2 additions & 2 deletions src/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,9 @@
<let name="xml-lang-value" value="@xml:lang"/>
<let name="languages" value="'languages.xml'"/>
<let name="subtag-description" value="string-join(document($languages)//*:item[@subtag=$xml-lang-value]/*:description,' / ')"/>
<assert test="exists($subtag-description)" role="error" id="abstract-lang-test-1">[abstract-lang-test-1] The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>
<assert test="$subtag-description!=''" role="error" id="abstract-lang-test-1">[abstract-lang-test-1] The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>

<report test="exists($subtag-description)" role="warning" id="abstract-lang-test-2">[abstract-lang-test-2] <name/> has an xml:lang attribute with the value '<value-of select="$xml-lang-value"/>', which corresponds to the following language: <value-of select="$subtag-description"/>. Please check this is correct.</report>
<report test="$subtag-description!=''" role="warning" id="abstract-lang-test-2">[abstract-lang-test-2] <name/> has an xml:lang attribute with the value '<value-of select="$xml-lang-value"/>', which corresponds to the following language: <value-of select="$subtag-description"/>. Please check this is correct.</report>
</rule></pattern>

<pattern id="front-permissions-tests-pattern"><rule context="front[journal-meta/lower-case(journal-id[1])='elife']//permissions" id="front-permissions-tests">
Expand Down
8 changes: 4 additions & 4 deletions src/rp-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -5600,9 +5600,9 @@
<xsl:variable name="subtag-description" select="string-join(document($languages)//*:item[@subtag=$xml-lang-value]/*:description,' / ')"/>
<!--ASSERT error-->
<xsl:choose>
<xsl:when test="exists($subtag-description)"/>
<xsl:when test="$subtag-description!=''"/>
<xsl:otherwise>
<svrl:failed-assert xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="exists($subtag-description)">
<svrl:failed-assert xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="$subtag-description!=''">
<xsl:attribute name="id">abstract-lang-test-1</xsl:attribute>
<xsl:attribute name="role">error</xsl:attribute>
<xsl:attribute name="location">
Expand All @@ -5617,8 +5617,8 @@
</xsl:otherwise>
</xsl:choose>
<!--REPORT warning-->
<xsl:if test="exists($subtag-description)">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="exists($subtag-description)">
<xsl:if test="$subtag-description!=''">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="$subtag-description!=''">
<xsl:attribute name="id">abstract-lang-test-2</xsl:attribute>
<xsl:attribute name="role">warning</xsl:attribute>
<xsl:attribute name="location">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<let name="xml-lang-value" value="@xml:lang"/>
<let name="languages" value="'../../../../../src/languages.xml'"/>
<let name="subtag-description" value="string-join(document($languages)//*:item[@subtag=$xml-lang-value]/*:description,' / ')"/>
<assert test="exists($subtag-description)" role="error" id="abstract-lang-test-1">[abstract-lang-test-1] The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>
<assert test="$subtag-description!=''" role="error" id="abstract-lang-test-1">[abstract-lang-test-1] The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>
</rule>
</pattern>
<pattern id="root-pattern">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<let name="xml-lang-value" value="@xml:lang"/>
<let name="languages" value="'../../../../../src/languages.xml'"/>
<let name="subtag-description" value="string-join(document($languages)//*:item[@subtag=$xml-lang-value]/*:description,' / ')"/>
<report test="exists($subtag-description)" role="warning" id="abstract-lang-test-2">[abstract-lang-test-2] <name/> has an xml:lang attribute with the value '<value-of select="$xml-lang-value"/>', which corresponds to the following language: <value-of select="$subtag-description"/>. Please check this is correct.</report>
<report test="$subtag-description!=''" role="warning" id="abstract-lang-test-2">[abstract-lang-test-2] <name/> has an xml:lang attribute with the value '<value-of select="$xml-lang-value"/>', which corresponds to the following language: <value-of select="$subtag-description"/>. Please check this is correct.</report>
</rule>
</pattern>
<pattern id="root-pattern">
Expand Down
4 changes: 2 additions & 2 deletions test/xspec/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,9 @@
<let name="xml-lang-value" value="@xml:lang"/>
<let name="languages" value="'languages.xml'"/>
<let name="subtag-description" value="string-join(document($languages)//*:item[@subtag=$xml-lang-value]/*:description,' / ')"/>
<assert test="exists($subtag-description)" role="error" id="abstract-lang-test-1">The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>
<assert test="$subtag-description!=''" role="error" id="abstract-lang-test-1">The xml:lang attribute on <name/> must contain one of the IETF RFC 5646 subtags. '<value-of select="@xml:lang"/>' is not one of these values.</assert>

<report test="exists($subtag-description)" role="warning" id="abstract-lang-test-2">
<report test="$subtag-description!=''" role="warning" id="abstract-lang-test-2">
<name/> has an xml:lang attribute with the value '<value-of select="$xml-lang-value"/>', which corresponds to the following language: <value-of select="$subtag-description"/>. Please check this is correct.</report>
</rule>
</pattern>
Expand Down

0 comments on commit 0c04de8

Please sign in to comment.