Skip to content

Commit

Permalink
Use 'return if ... else' syntax instead of where for XQuery in variable
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Nov 22, 2023
1 parent 21df03a commit 17049b5
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/final-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<report test="(@contrib-type='senior_editor') and ($role!='Senior Editor')" role="error" id="editor-conformance-3">[editor-conformance-3] <value-of select="$name"/> has a @contrib-type='senior_editor' but their role is not 'Senior Editor' (<value-of select="$role"/>), which is incorrect.</report>

Expand Down
2 changes: 1 addition & 1 deletion src/final-JATS-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7842,7 +7842,7 @@
<xsl:variable name="name" select="e:get-name(name[1])"/>
<xsl:variable name="role" select="role[1]"/>
<xsl:variable name="author-contribs" select="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<xsl:variable name="matching-author-names" select="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<xsl:variable name="matching-author-names" select="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<!--REPORT error-->
<xsl:if test="(@contrib-type='senior_editor') and ($role!='Senior Editor')">
Expand Down
2 changes: 1 addition & 1 deletion src/final-package-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<report test="(@contrib-type='senior_editor') and ($role!='Senior Editor')" role="error" id="editor-conformance-3"><value-of select="$name"/> has a @contrib-type='senior_editor' but their role is not 'Senior Editor' (<value-of select="$role"/>), which is incorrect.</report>

Expand Down
2 changes: 1 addition & 1 deletion src/pre-JATS-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<report test="(@contrib-type='senior_editor') and ($role!='Senior Editor')" role="error" id="editor-conformance-3">[editor-conformance-3] <value-of select="$name"/> has a @contrib-type='senior_editor' but their role is not 'Senior Editor' (<value-of select="$role"/>), which is incorrect.</report>

Expand Down
2 changes: 1 addition & 1 deletion src/pre-JATS-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7742,7 +7742,7 @@
<xsl:variable name="name" select="e:get-name(name[1])"/>
<xsl:variable name="role" select="role[1]"/>
<xsl:variable name="author-contribs" select="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<xsl:variable name="matching-author-names" select="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<xsl:variable name="matching-author-names" select="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<!--REPORT error-->
<xsl:if test="(@contrib-type='senior_editor') and ($role!='Senior Editor')">
Expand Down
2 changes: 1 addition & 1 deletion src/schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<report test="(@contrib-type='senior_editor') and ($role!='Senior Editor')"
role="error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>
<report test="(@contrib-type='senior_editor') and ($role!='Senior Editor')" role="error" id="editor-conformance-3">
<value-of select="$name"/> has a @contrib-type='senior_editor' but their role is not 'Senior Editor' (<value-of select="$role"/>), which is incorrect.</report>
</rule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>
<report test="(@contrib-type='editor') and ($role!='Reviewing Editor')" role="error" id="editor-conformance-4">
<value-of select="$name"/> has a @contrib-type='editor' but their role is not 'Reviewing Editor' (<value-of select="$role"/>), which is incorrect.</report>
</rule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>
<assert test="count($matching-author-names)=0" role="error" id="editor-conformance-5">
<value-of select="$name"/> is listed both as an author as as a <value-of select="$role"/>, which must be incorrect.</assert>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion test/xspec/schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@
<let name="name" value="e:get-name(name[1])"/>
<let name="role" value="role[1]"/>
<let name="author-contribs" value="ancestor::article-meta/contrib-group[1]/contrib[@contrib-type='author']"/>
<let name="matching-author-names" value="for $contrib in $author-contribs where (e:get-name($contrib)=$name) return e:get-name($contrib)"/>
<let name="matching-author-names" value="for $contrib in $author-contribs return if (e:get-name($contrib)=$name) then e:get-name($contrib) else ()"/>

<report test="(@contrib-type='senior_editor') and ($role!='Senior Editor')" role="error" id="editor-conformance-3">
<value-of select="$name"/> has a @contrib-type='senior_editor' but their role is not 'Senior Editor' (<value-of select="$role"/>), which is incorrect.</report>
Expand Down

0 comments on commit 17049b5

Please sign in to comment.