Schematron: catch inconsistent spelling

<oXygen/> general issues.
Posts: 131
Location: USA

Schematron: catch inconsistent spelling

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
Posts: 163

Re: Schematron: catch inconsistent spelling

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

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 4 guests