-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample code for "Testing Schematron Messages with XSpec 3.0" (#38)
- Loading branch information
Showing
9 changed files
with
194 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
|
||
Primary example files: | ||
|
||
* `schematron-messages.sch` | ||
* `schematron-messages.xspec` | ||
* `schematron-messages.xml` | ||
|
||
"Verifying Report Messages": | ||
|
||
* `schematron-messages-report.sch` | ||
* `schematron-messages-report.xspec` | ||
|
||
"Verifying Diagnostic Messages": | ||
|
||
* `schematron-messages-with-diag.sch` | ||
* `schematron-messages-with-diag.xspec` | ||
|
||
#### Link to Topic | ||
[Testing Schematron Messages with XSpec 3.0](https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> | ||
|
||
<!-- | ||
Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d | ||
--> | ||
|
||
<!-- "Verifying Report Messages" --> | ||
<sch:pattern> | ||
<sch:rule context="section/section/info"> | ||
<sch:let name="top-section-title" | ||
value="ancestor::section[last()]/title"/> | ||
<sch:report test="true()" id="subsection-no-info"> | ||
Subsection must not contain info. Move children to | ||
"<sch:value-of select="$top-section-title"/>" info. | ||
</sch:report> | ||
</sch:rule> | ||
</sch:pattern> | ||
|
||
</sch:schema> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description | ||
schematron="schematron-messages-report.sch" | ||
xmlns:svrl="http://purl.oclc.org/dsdl/svrl" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec" | ||
version="3.0"> | ||
|
||
<!-- | ||
Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d | ||
--> | ||
|
||
<!-- This test requires XSpec 3.0 --> | ||
|
||
<!-- "Verifying Report Messages" --> | ||
<x:scenario label="Subsection with info element"> | ||
<x:context href="schematron-messages.xml"/> | ||
<x:expect-report | ||
id="subsection-no-info"> | ||
Subsection must not contain info. | ||
Move children to "Top-Level Section" info. | ||
</x:expect-report> | ||
</x:scenario> | ||
|
||
</x:description> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> | ||
|
||
<!-- | ||
Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d | ||
--> | ||
|
||
<!-- "Defining Diagnostic Messages" --> | ||
|
||
<sch:pattern> | ||
<sch:rule context="section/section/info"> | ||
<sch:let name="top-section-title" | ||
value="ancestor::section[last()]/title"/> | ||
<sch:assert test="false()" id="subsection-no-info" | ||
diagnostics="guideline-1-2"> | ||
Subsection must not contain info. Move children to | ||
"<sch:value-of select="$top-section-title"/>" info. | ||
</sch:assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
|
||
<sch:diagnostics> | ||
<sch:diagnostic id="guideline-1-2">[WG 1.2]</sch:diagnostic> | ||
<sch:diagnostic id="guideline-1-3">[WG 1.3]</sch:diagnostic> | ||
<!-- More diagnostic definitions can go here --> | ||
</sch:diagnostics> | ||
</sch:schema> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |
29 changes: 29 additions & 0 deletions
29
src/schematron-messages/schematron-messages-with-diag.xspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description | ||
schematron="schematron-messages-with-diag.sch" | ||
xmlns:svrl="http://purl.oclc.org/dsdl/svrl" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec" | ||
version="3.0"> | ||
|
||
<!-- | ||
Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d | ||
--> | ||
|
||
<!-- This test requires XSpec 3.0 --> | ||
|
||
<!-- "Verifying Diagnostic Messages" --> | ||
<x:scenario label="Subsection with info element"> | ||
<x:context href="schematron-messages.xml"/> | ||
<x:expect-assert | ||
id="subsection-no-info"> | ||
Subsection must not contain info. | ||
Move children to "Top-Level Section" info. | ||
</x:expect-assert> | ||
<x:expect-assert label="Check diagnostic:" | ||
id="subsection-no-info">[WG 1.2] q</x:expect-assert> | ||
</x:scenario> | ||
|
||
</x:description> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> | ||
|
||
<!-- | ||
Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d | ||
--> | ||
|
||
<sch:pattern> | ||
<sch:rule context="section/section/info"> | ||
<sch:let name="top-section-title" | ||
value="ancestor::section[last()]/title"/> | ||
<sch:assert test="false()" id="subsection-no-info"> | ||
Subsection must not contain info. Move children to | ||
"<sch:value-of select="$top-section-title"/>" info. | ||
</sch:assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
|
||
</sch:schema> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-model href="schematron-messages.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> | ||
<section xml:id="top-section"> | ||
<title>Top-Level Section</title> | ||
<info xml:id="top-info"><!-- metadata belongs here --></info> | ||
<para>Introductory content</para> | ||
<section> | ||
<title>Subsection</title> | ||
<info> | ||
<authorinitials>TSE</authorinitials> | ||
</info> | ||
<para>Subsection content</para> | ||
</section> | ||
</section> | ||
<!-- Copyright © 2024 by Amanda Galtman. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description | ||
schematron="schematron-messages.sch" | ||
xmlns:svrl="http://purl.oclc.org/dsdl/svrl" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec" | ||
version="3.0"> | ||
|
||
<!-- | ||
Sample code for "Testing Schematron Messages with XSpec 3.0" | ||
https://medium.com/@xspectacles/testing-schematron-messages-with-xspec-3-0-1adc9be69a4d | ||
--> | ||
|
||
<!-- This test requires XSpec 3.0 --> | ||
|
||
<x:scenario label="Subsection with info element"> | ||
<x:context href="schematron-messages.xml"/> | ||
<x:expect-assert | ||
id="subsection-no-info"> | ||
Subsection must not contain info. | ||
Move children to "Top-Level Section" info. | ||
</x:expect-assert> | ||
</x:scenario> | ||
|
||
</x:description> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |