Page 1 of 1

Providing the same sqf:fix for multiple reports

Posted: Fri Jun 26, 2015 12:16 pm
by Patrik
Hi,

I have following schematron rule with quick-fixes:

Code: Select all

<sch:rule context="Element[text()]">
<sch:report test="matches(text(), '^\s')" sqf:fix="remove-leading-spaces normalize-spaces">
Leading spaces!
</sch:report>
<sch:report test="matches(text(), '\s+')" sqf:fix="remove-multiple-spaces normalize-spaces">
Multiple spaces!
</sch:report>
<sch:report test="matches(text(), '\s$')" sqf:fix="remove-trailing-spaces normalize-spaces">
Trailing spaces!
</sch:report>

<sqf:fix id="remove-leading-spaces">
<sqf:description>
<sqf:title>Remove leading spaces.</sqf:title>
</sqf:description>
<sqf:stringReplace regex="^\s+" select="''"/>
</sqf:fix>
<sqf:fix id="remove-trailing-spaces">
<sqf:description>
<sqf:title>Remove trailing spaces.</sqf:title>
</sqf:description>
<sqf:stringReplace regex="^\s+" select="''"/>
</sqf:fix>
<sqf:fix id="remove-multiple-spaces">
<sqf:description>
<sqf:title>Remove leading spaces.</sqf:title>
</sqf:description>
<sqf:stringReplace regex="^\s\s+" select="' '"/>
</sqf:fix>
<sqf:fix id="normalize-spaces">
<sqf:description>
<sqf:title>Normalize spaces.</sqf:title>
</sqf:description>
<sqf:replace match="text()" select="normalize-space(.)"/>
</sqf:fix>
</sch:rule>
Now when validating this input:

Code: Select all

<Element> Text  Text </Element>
I get this list of quick-fixes:
  • Issue: Leading spaces!
    • Fix: Remove leading spaces.
  • Issue: Trailing spaces!
    • Fix: Normalize spaces.
  • Issue: Multiple spaces!
    • Fix: Remove leading spaces.
  • Issue: Trailing spaces!
    • Fix: Normalize spaces.
    • Fix: Remove trailing spaces.
    • Fix: Normalize spaces.
But I'd expect to get two fixes for reach issue: "remove * spaces" and "Normalize spaces".

I'm wondering if there is a way to make more clear the the fix "Normalize spaces" solves all three issues. This could be even more useful when you have very different isues but want to provide a fix that solves as much issues as possible with just one click. An attempt would be to add a horizontal seperator and invert the relation. That is: list the fixes together with the issues the would solve. In this case it would look like this:
  • Issue: Leading spaces!
    • Fix: Remove leading spaces.
  • Issue: Multiple spaces!
    • Fix: Remove multiple spaces.
  • Issue: Trailing spaces!
    • Fix: Remove trailing spaces.
    ----- Fixes for multiple issues: -----
  • Fix: Normalize spaces.
    • Issue: Leading spaces!
    • Issue: Multiple spaces!
    • Issue: Trailing spaces!
Just a thought, though...

Regards,

Patrik

Re: Providing the same sqf:fix for multiple reports

Posted: Fri Jun 26, 2015 4:34 pm
by tavy
Hi Patrik,

The quick fixes are grouped by the error message, and in your case for each error you should have 2 quick fixes.
  • Issue: Leading spaces!
  • Fix: Remove leading spaces.
  • Fix: Normalize spaces.
    Issue: Multiple spaces!
  • Fix: Remove leading spaces.
  • Fix: Normalize spaces.
    Issue: Trailing spaces!
  • Fix: Remove trailing spaces.
  • Fix: Normalize spaces.
In your example the quick fixes are not presented correct. I added an issue for this on our issue tracker.
About grouping of the fixes in other way, I don't know, I think it is better to see the problem and the fixes for problem grouped.

By the way the quick fixes that you created are not correct. The sqf:stringReplace operation should match a text node, but in your example matches an element. You need to add the match="text()" on the sqf:stringReplace operation.

Best Regards,
Octavian

Re: Providing the same sqf:fix for multiple reports

Posted: Mon Jan 04, 2016 5:53 pm
by tavy
Hello,

Please note that the issue that you reported was fixed in oXygen 17.1.

Best Regards,
Octavian