Page 1 of 1

Schematron: catch inconsistent spelling

Posted: Tue Feb 12, 2019 2:18 am
by shudson310
One of the features in Vale is that it can catch inconsistent use of a particular spelling. For example, "cancelled" and "canceled" can both be accepted forms of the word. I want to write a Schematron rule that flags a document that uses both forms of the word! You can use one or the other forms, but not both.

What would you suggest for such a rule?

Re: Schematron: catch inconsistent spelling

Posted: Tue Feb 12, 2019 10:14 am
by tavy
Hello Scott,

One solution is to check if both words are used in the document and highlight one of the words. You can also propose a quick fix that will replace all occurrences of an word with another, something like this:

Code: Select all


<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:let name="firstCancelled" value="(//text()[contains(., 'cancelled')])[1]"/>
<sch:pattern>
<sch:rule context="text()[contains(., 'canceled')]">
<sch:report test="$firstCancelled" sqf:fix="replaceWithCancelled replaceWithCanceled"> Both 'cancelled' and
'canceled' are used. </sch:report>

<sqf:fix id="replaceWithCancelled">
<sqf:description>
<sqf:title>Replace all 'canceled' occurances with 'cancelled'</sqf:title>
</sqf:description>
<sqf:stringReplace match="//text()[contains(., 'canceled')]" regex="canceled" select="'cancelled'"/>
</sqf:fix>

<sqf:fix id="replaceWithCanceled">
<sqf:description>
<sqf:title>Replace all 'cancelled' occurances with 'canceled'</sqf:title>
</sqf:description>
<sqf:stringReplace match="//text()[contains(., 'cancelled')]" regex="cancelled" select="'canceled'"/>
</sqf:fix>

</sch:rule>
</sch:pattern>
</sch:schema>
Best Regards,
Octavian