Quick fix fails silently

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
bburns
Posts: 12
Joined: Mon Jun 19, 2017 11:24 pm

Quick fix fails silently

Post by bburns » Tue Jul 09, 2019 10:43 pm

I have a schematron rule that checks for the substring 911 in various contexts. I want to replace the string with an empty element that will be used to automatically generate the emergency number for each locale. The initial test works, but the quick fix does not. I get no error, but nothing happens.

<rule context="title | navtitle | p | dt | dd | li | cmd" role="info">
<report test="contains(., '911')" role="warn" sqf:fix="replace911text">All 911 text should be replaced with emnumber.</report>
<sqf:fix id="replace911text">
<sqf:description>
<sqf:title>Replace text 911 with the emnumber tag.</sqf:title>
</sqf:description>
<sqf:stringReplace regex="911">
<emnumber/>
</sqf:stringReplace>
</sqf:fix>
</rule>

My fix is almost identical to one shown at https://td-demo.titaniasoftware.com/por ... operations, which I assume works.

Any suggestions?

Thanks,
Bill
Bill Burns
Content Architect | Healthwise
bburns@healthwise.org | www.healthwise.org
208.331.6917 (office) | 208.345.1897 (fax)

Healthwise helps people make better health decisions.

tavy
Posts: 184
Joined: Thu Jul 01, 2004 12:29 pm

Re: Quick fix fails silently

Post by tavy » Wed Jul 10, 2019 9:32 am

Hi Bill,

The sqf:stringReplace operation applies only on text nodes. The context of your rule are element nodes (title | navtitle | p | dt | dd | li | cmd), and this is why the quick fix does not work. Therefore, you need to specify that the quick fix will match the text from the current element using match="text()". Also I recommend to use a prefix for the Schematron elements otherwise the <emnumber/> element will be considered to be in the Schematron namespace, and you want to be in no namespace. The Schematron should look 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:pattern>
        <sch:rule context="title | navtitle | p | dt | dd | li | cmd" role="info">
            <sch:report test="contains(., '911')" role="warn" sqf:fix="replace911text">All 911 text should be replaced with emnumber.</sch:report>
            <sqf:fix id="replace911text">
                <sqf:description>
                    <sqf:title>Replace text 911 with the emnumber tag.</sqf:title>
                </sqf:description>
                <sqf:stringReplace match="text()" regex="911">
                    <emnumber/>
                </sqf:stringReplace>
            </sqf:fix>
        </sch:rule>
    </sch:pattern>
</sch:schema>
Probably we should show an error in case the quick fix does not work, and explain what happen. I will add an issue on our internal issue tracker for this. Thanks for your feedback.

You can read more about the SQF stringReplace operation in our User manual:
https://www.oxygenxml.com/doc/versions/ ... ng-replace

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

bburns
Posts: 12
Joined: Mon Jun 19, 2017 11:24 pm

Re: Quick fix fails silently

Post by bburns » Thu Jul 11, 2019 4:58 pm

Thanks, Octavian. That worked. Still finding my way around some of the functions. I tried using matches() in the report node test as in the example, and that didn't work, so I didn't think to use it once I'd matched the substring.
Bill Burns
Content Architect | Healthwise
bburns@healthwise.org | www.healthwise.org
208.331.6917 (office) | 208.345.1897 (fax)

Healthwise helps people make better health decisions.

bburns
Posts: 12
Joined: Mon Jun 19, 2017 11:24 pm

Re: Quick fix fails silently

Post by bburns » Mon Jul 15, 2019 6:40 pm

Incidently, can these quick fixes be run automatically outside of the Oxygen environment? I haven't seen their use anywhere else.
Bill Burns
Content Architect | Healthwise
bburns@healthwise.org | www.healthwise.org
208.331.6917 (office) | 208.345.1897 (fax)

Healthwise helps people make better health decisions.

tavy
Posts: 184
Joined: Thu Jul 01, 2004 12:29 pm

Re: Quick fix fails silently

Post by tavy » Tue Jul 16, 2019 3:51 pm

Hi Bill,

The quick fixes can be run only inside Oxygen, we so not have support to run them outside.
You can try to use Escali engine, that also supports Schematron Quick Fixes:
https://github.com/schematron-quickfix/escali-package

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply