Schematron: catch inconsistent spelling

<oXygen/> general issues.
Posts: 149
Joined: Sat Feb 26, 2005 12:09 am
Location: USA

Schematron: catch inconsistent spelling

Post by shudson310 » Tue Feb 12, 2019 2:18 am

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?
Scott Hudson
Staff Content Engineer

Posts: 280
Joined: Thu Jul 01, 2004 12:29 pm

Re: Schematron: catch inconsistent spelling

Post by tavy » Tue Feb 12, 2019 10:14 am

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="" queryBinding="xslt2"
<sch:let name="firstCancelled" value="(//text()[contains(., 'cancelled')])[1]"/>
<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:title>Replace all 'canceled' occurances with 'cancelled'</sqf:title>
<sqf:stringReplace match="//text()[contains(., 'canceled')]" regex="canceled" select="'cancelled'"/>

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

Best Regards,
Octavian Nadolu
<oXygen/> XML Editor

Post Reply