Schematron: catch inconsistent spelling

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

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
Content Strategist
Jeppesen
Site: jeppesen.com

tavy
Posts: 189
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="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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply