Providing the same sqf:fix for multiple reports

This should cover W3C XML Schema, Relax NG and DTD related problems.
Patrik
Posts: 216
Location: Hamburg/Germany

Providing the same sqf:fix for multiple reports

Fri Jun 26, 2015 12:16 pm

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
tavy
Posts: 122

Re: Providing the same sqf:fix for multiple reports

Fri Jun 26, 2015 4:34 pm

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

Re: Providing the same sqf:fix for multiple reports

Mon Jan 04, 2016 5:53 pm

Hello,

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

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

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 1 guest