Generate Multiple Similar Quick Fixes
You can generate the same Schematron Quick
Fix for multiple matches. To do this, you can add the
@use-for-each
attribute inside the <sqf:fix>
element
and for each match of the XPath expression in the value of the @use-for-each
attribute, a Quick Fix will be presented to the user. The XPath expression does not change the
context of the Quick Fix. If you want to access the current match from the XPath expression,
you can use the $sqf:current
variable.
Example:
Suppose you want to restrict the user from entering more than 4 list items in a list. The following example presents an error on any list that has more than 4 list items and offers a Quick Fix with multiple proposals where the user would specify which list item to remove.
<sch:rule context="ul">
<sch:report test="count(li) gt 4" sqf:fix="removeAnyItem">
The list cannot contain more than 4 entries.
</sch:report>
<sqf:fix id="removeAnyItem" use-for-each="1 to count(li)">
<sqf:description>
<sqf:title>Remove item #<sch:value-of select="$sqf:current"/></sqf:title>
</sqf:description>
<sqf:delete match="li[$sqf:current]"/>
</sqf:fix>
</sch:rule>