Edit online

You can use Schematron Quick Fixes to assist your content authors by imposing rules for an entire framework (document type) and offering fixes when a rule violation is detected.

For example, if you are using DITA, you may want your contributors to avoid inserting a figure (<fig> element) inside a paragraph (<p> element) that contains other content since it may result in undesirable placement or spacing in the output. The Schematron rule and its Quick Fix for this particular use-case could look like this:

<schema xmlns="http://purl.oclc.org/dsdl/schematron"
   <pattern id="check.figure.location">
     <rule context="p/fig">
         <report test="true()" role="warn" sqf:fix="moveAfter">
         A figure inside a paragraph doesn't transform well into PDF. </report>
         <sqf:fix id="moveAfter">
                 <sqf:title>Move after the paragraph.</sqf:title>
             <let name="figToMove" value="."/>
             <sqf:add match="parent::p" select="$figToMove" position="after"/>
             <sqf:delete match="."/>

The result of this example would be that the user will see a warning if they insert a <fig> element inside a <p> element and they are presented with the option of selecting the Quick Fix that would move the figure outside the paragraph.

How to Integrate SQF in a Framework

To integrate a Schematron Quick Fix in a framework, follow these steps:
  1. Create a folder structure for an extended framework and save it somewhere on disk where you have full write access (for example, custom_frameworks/dita-extension).
  2. In that new folder structure, create another folder that will contain all of your custom Schematron files (for example, custom_frameworks/dita-extension/rules).
  3. Define the Schematron Quick Fix for a rule in an existing or new Schematron file and save it in the folder you created in step 2.
  4. Open the Preferences dialog box (Options > Preferences) and go to Document Type Association > Locations. In this preferences page, add the path to your custom_frameworks folder in the Additional frameworks directories list, then click OK or Apply to save your changes.
  5. Go to the Document Type Association preferences page and select a framework configuration (for example, DITA) and use the Extend button to create an extension for it.
  6. Give the extension an appropriate name (for example, DITA - Custom), select External for the Storage option, and specify an appropriate path to your framework configuration file (for example, path/to/.../custom_frameworks/dita-extension/dita-extension.framework).
  7. Make whatever changes you desire to the extension, then go to the Validation tab, edit the default validation scenario (select the scenario and click the Edit button), and add an extra validation unit to it (one that uses your custom Schematron file that includes the SQF).
  8. Click OK to close the dialog box and then OK or Apply to save the changes to the Document Type Association preferences page.
  9. Add a reference to the Schematron file that includes the SQF in your framework by following the procedure in Associating a Schema in Validation Scenarios Defined in the Document Type.
  10. Open a document in your framework and test the new rule and Quick Fix.
  11. You can continue to refine the Schematron and develop additional rules as needed.

Sharing Schematron Quick Fixes

To share Schematron Quick Fixes with other members of your team, you simply need to share the framework where you integrated the SQF.