Integrating SQF in a Framework and Sharing Them
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"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
queryBinding="xslt2">
<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:description>
<sqf:title>Move after the paragraph.</sqf:title>
</sqf:description>
<let name="figToMove" value="."/>
<sqf:add match="parent::p" select="$figToMove" position="after"/>
<sqf:delete match="."/>
</sqf:fix>
</rule>
</pattern>
</schema>
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
- 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).
- In that new folder structure, create another folder that will contain all of your custom Schematron files (for example, custom_frameworks/dita-extension/rules).
- 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.
- Open the Preferences dialog box and go to . 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.
- 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.
- 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).
- 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).
- Click OK to close the dialog box and then OK or Apply to save the changes to the Document Type Association preferences page.
- 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.
- Open a document in your framework and test the new rule and Quick Fix.
- 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.