Using XSLT to Generate Content

A Schematron QuickFix can also be used to improve efficiency when adding content in XML documents. You can define actions that will automatically add a new XML structure in the document at a valid location, or actions that will convert an XML structure into another. These types of actions will help the content writer add content more easily and without making mistakes.

Using XSLT, you can create complex actions. For example, actions that will correct a table layout and use complex XSLT processing, or actions that use data from other documents or from a database. This will allow the content writer to focus on the content of the document while the quick fixes will help them to easily insert XML structure or to fix various issues that can appear during editing.

If you have a rule that checks if a table layout is correct and you have the same number of cells on each row, you can create a quick fix that adds the missing cells. To do this, you can use XSLT to calculate and generate the exact number of cells that are missing on each row.

Example 7. Add the missing cells from a table

<sqf:fix id="addCells">
      <sqf:title>Add enough empty cells on each row</sqf:title>
  <sch:let name="reqColumsNo" value="max(.//row/count(entry))"/>
  <sqf:add match="row" position="last-child">
      <sch:let name="columnNo" value="count(entry)"/>
      <xsl:for-each select="1 to xs:integer($reqColumsNo - $columnNo)">