Skip to content

Commit

Permalink
RP - upgrade to error and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Feb 24, 2025
1 parent 6a69b20 commit 873c616
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/rp-schematron-base.sch
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
id="book-ref-pub-name-1">This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a publisher-name with italics and no chapter-title element. Have all the details been captured correctly?</report>

<report test="descendant::article-title"
role="warning"
role="error"
id="book-ref-article-title">This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
</rule>

Expand Down
2 changes: 1 addition & 1 deletion src/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@

<report test="not(chapter-title) and publisher-name[italic]" role="warning" id="book-ref-pub-name-1">[book-ref-pub-name-1] This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a publisher-name with italics and no chapter-title element. Have all the details been captured correctly?</report>

<report test="descendant::article-title" role="warning" id="book-ref-article-title">[book-ref-article-title] This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
<report test="descendant::article-title" role="error" id="book-ref-article-title">[book-ref-article-title] This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
</rule></pattern><pattern id="book-ref-source-checks-pattern"><rule context="mixed-citation[@publication-type='book']/source" id="book-ref-source-checks">

<report test="matches(lower-case(.),'^chapter\s|\s+chapter\s+')" role="warning" id="book-source-1">[book-source-1] The source in book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) contains 'chapter' - <value-of select="."/>. Are the details captured correctly?</report>
Expand Down
4 changes: 2 additions & 2 deletions src/rp-schematron.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -3018,11 +3018,11 @@
<xsl:text/>) has a publisher-name with italics and no chapter-title element. Have all the details been captured correctly?</svrl:text>
</svrl:successful-report>
</xsl:if>
<!--REPORT warning-->
<!--REPORT error-->
<xsl:if test="descendant::article-title">
<svrl:successful-report xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="descendant::article-title">
<xsl:attribute name="id">book-ref-article-title</xsl:attribute>
<xsl:attribute name="role">warning</xsl:attribute>
<xsl:attribute name="role">error</xsl:attribute>
<xsl:attribute name="location">
<xsl:apply-templates select="." mode="schematron-select-full-path"/>
</xsl:attribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</xsl:function>
<pattern id="book-ref-checks-pattern">
<rule context="mixed-citation[@publication-type='book']" id="book-ref-checks">
<report test="descendant::article-title" role="warning" id="book-ref-article-title">[book-ref-article-title] This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
<report test="descendant::article-title" role="error" id="book-ref-article-title">[book-ref-article-title] This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
</rule>
</pattern>
<pattern id="root-pattern">
Expand Down
11 changes: 10 additions & 1 deletion test/tests/rp/book-ref-checks/book-ref-article-title/fail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
<!--Context: mixed-citation[@publication-type='book']
Test: report descendant::article-title
Message: This book reference () has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely). -->
<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/></root>
<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>
<mixed-citation publication-type="book">
<person-group person-group-type="author"><string-name><surname>Feyerabend</surname> <given-names>P</given-names></string-name></person-group>
(<year>1975</year>)
<article-title>Against method</article-title>
<publisher-name>New Left Books</publisher-name>
</mixed-citation>
</article>
</root>
11 changes: 10 additions & 1 deletion test/tests/rp/book-ref-checks/book-ref-article-title/pass.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
<!--Context: mixed-citation[@publication-type='book']
Test: report descendant::article-title
Message: This book reference () has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely). -->
<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/></root>
<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>
<mixed-citation publication-type="book">
<person-group person-group-type="author"><string-name><surname>Feyerabend</surname> <given-names>P</given-names></string-name></person-group>
(<year>1975</year>)
<source>Against method</source>
<publisher-name>New Left Books</publisher-name>
</mixed-citation>
</article>
</root>
2 changes: 1 addition & 1 deletion test/xspec/rp-schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@

<report test="not(chapter-title) and publisher-name[italic]" role="warning" id="book-ref-pub-name-1">This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a publisher-name with italics and no chapter-title element. Have all the details been captured correctly?</report>

<report test="descendant::article-title" role="warning" id="book-ref-article-title">This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
<report test="descendant::article-title" role="error" id="book-ref-article-title">This book reference (<value-of select="if (ancestor::ref/@id) then concat('id ',ancestor::ref/@id) else 'no id'"/>) has a descendant article-title. This cannot be correct. It should either be a source or chapter-title (or something else entirely).</report>
</rule>
</pattern>
<pattern id="book-ref-source-checks-pattern">
Expand Down
4 changes: 2 additions & 2 deletions test/xspec/rp-schematron.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -931,12 +931,12 @@
</x:scenario>
<x:scenario label="book-ref-article-title-pass">
<x:context href="../tests/rp/book-ref-checks/book-ref-article-title/pass.xml"/>
<x:expect-not-report id="book-ref-article-title" role="warning"/>
<x:expect-not-report id="book-ref-article-title" role="error"/>
<x:expect-not-assert id="book-ref-checks-xspec-assert" role="error"/>
</x:scenario>
<x:scenario label="book-ref-article-title-fail">
<x:context href="../tests/rp/book-ref-checks/book-ref-article-title/fail.xml"/>
<x:expect-report id="book-ref-article-title" role="warning"/>
<x:expect-report id="book-ref-article-title" role="error"/>
<x:expect-not-assert id="book-ref-checks-xspec-assert" role="error"/>
</x:scenario>
</x:scenario>
Expand Down

0 comments on commit 873c616

Please sign in to comment.