Edit online

Integrating Schematron Rules in a Framework and Sharing Them

Custom Schematron rules are a great way to ensure consistency for XML authoring, especially when there is a large team working on the same set of documents. You can use Schematron for numerous use cases. For example, to restrict certain elements from being used, to impose restrictions on the amount of text for an element, or to impose restrictions on certain elements based on various attribute values or text content set in other elements. Furthermore, you can define quick fixes for each Schematron rule to offer technical writers proposed solutions for reported problems.

Once you define the Schematron rules, they can be shared with the other members of your team by integrating them in a framework (document type) configuration.

How to Integrate Schematron Rules in a Framework

To integrate a Schematron rule in an existing framework bundled with the application, 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 rules in an existing or new Schematron file and save it in the folder you created in step 2. There are numerous online resources out there to help you get started with writing Schematron rules. Here are just a few that might help you:
  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). For more details about editing validation scenarios, see Configuring Validation Scenarios for a Framework.
  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. Open an XML document that matches your framework configuration and test the new rule.
  10. You can continue to refine the Schematron and develop additional rules as needed.

Sharing Schematron Rules

To share Schematron rules with other members of your team, you simply need to share the framework where you integrated the Schematron rules. There are several methods for sharing frameworks and you can find details here: Sharing a Framework.