-
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 files for "Text Nodes and Locations in XSpec Tests for Schemat…
…ron" (#42)
- Loading branch information
Showing
7 changed files
with
119 additions
and
2 deletions.
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
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,11 @@ | ||
# Sample code for "Text Nodes and Locations in XSpec Tests for Schematron" | ||
|
||
Example files: | ||
|
||
* `schxslt-in-xspec.sch` | ||
* `schxslt-in-xspec.xspec` | ||
* `schxslt-in-xspec-mistakes.xspec` | ||
* `document.xml` | ||
|
||
#### Link to Topic | ||
[Text Nodes and Locations in XSpec Tests for Schematron](https://medium.com/@xspectacles/text-nodes-and-locations-in-xspec-tests-for-schematron-2174e7c943b3) |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<topic> | ||
<info> | ||
<title>Schematron for Text Nodes</title> | ||
</info> | ||
<para xml:id="para-1"> Paragraph one</para> | ||
<para xml:id="para-2"><phrase>Paragraph</phrase> two</para> | ||
</topic> |
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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description | ||
schematron="schxslt-in-xspec.sch" | ||
version="3.0" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec"> | ||
|
||
<!-- | ||
Sample code for "Text Nodes and Locations in XSpec Tests for Schematron" | ||
https://medium.com/@xspectacles/text-nodes-and-locations-in-xspec-tests-for-schematron-2174e7c943b3 | ||
--> | ||
|
||
<x:scenario label="Mistake in location attribute"> | ||
<x:context href="document.xml"/> | ||
<x:pending label="Errors"> | ||
<x:expect-not-assert id="sp" | ||
location="//para[@xml:id='para2']/text()"/> | ||
<x:expect-not-assert id="sp" | ||
location="//para/text()"/> | ||
</x:pending> | ||
|
||
<!-- Troubleshooting --> | ||
<x:expect test="$x:context"> | ||
<x:label>What is in the document?</x:label> | ||
placeholder | ||
</x:expect> | ||
<x:expect test="$x:context//para[@xml:id='para2']/text()"> | ||
<x:label>What does location attribute find at | ||
//para[@xml:id='para2']/text() ? </x:label> | ||
placeholder | ||
</x:expect> | ||
<x:expect test="$x:context//para/text()"> | ||
<x:label>What does location attribute find at | ||
//para/text() ? </x:label> | ||
placeholder | ||
</x:expect> | ||
</x:scenario> | ||
|
||
<x:scenario label="Fix for mistake in location attribute"> | ||
<x:context href="document.xml"/> | ||
<x:expect-not-assert id="sp" | ||
location="//para[@xml:id='para-2']/text()"/> | ||
</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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema queryBinding="xslt2" | ||
xmlns:sch="http://purl.oclc.org/dsdl/schematron"> | ||
|
||
<!-- | ||
Sample code for "Text Nodes and Locations in XSpec Tests for Schematron" | ||
https://medium.com/@xspectacles/text-nodes-and-locations-in-xspec-tests-for-schematron-2174e7c943b3 | ||
--> | ||
|
||
<sch:pattern> | ||
<sch:rule context="para/node()[1]/self::text()"> | ||
<sch:assert test="not(starts-with(., ' '))" id="sp" | ||
>Paragraph must start with a word, not a space.</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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description | ||
schematron="schxslt-in-xspec.sch" | ||
version="3.0" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec"> | ||
|
||
<!-- | ||
Sample code for "Text Nodes and Locations in XSpec Tests for Schematron" | ||
https://medium.com/@xspectacles/text-nodes-and-locations-in-xspec-tests-for-schematron-2174e7c943b3 | ||
--> | ||
|
||
<x:scenario label="Paragraph starting with space"> | ||
<x:context href="document.xml"/> | ||
<x:expect-assert id="sp"/> | ||
<x:expect-assert id="sp" | ||
location="//para[@xml:id='para-1']/text()"/> | ||
<x:expect-assert id="sp" | ||
location="topic/para[@xml:id='para-1']/text()"/> | ||
<x:expect-assert id="sp" | ||
location="$x:context//para[@xml:id='para-1']/text()"/> | ||
</x:scenario> | ||
|
||
<!-- See schxslt-in-xspec-mistakes.xspec for tips | ||
on troubleshooting mistakes in location attribute. --> | ||
|
||
<x:scenario label="Fix for mistake in location attribute"> | ||
<x:context href="document.xml"/> | ||
<x:expect-not-assert id="sp" | ||
location="//para[@xml:id='para-2']/text()"/> | ||
</x:scenario> | ||
</x:description> | ||
|
||
<!-- Copyright © 2024 by Amanda Galtman. --> |