Schematron (fontoxml-schematron)

Use schematron and a side bar tab to report and fix content issues.

Getting started

This add-on can be added to an editor by selecting it in the list of add-ons available on the SDK portal. This can then be installed as usual.

A schematron document can be loaded using the SchematronManager#setSchema method.

The Schematron document should adhere to the schematron minimal syntax (see chapter 6.2 of the ISO spec for more info). It should use the ISO namespace (http://purl.oclc.org/dsdl/schematron).

Note that the current implementation is very simple: the document will be queried for nodes using an XPath query.

These queries may have the form of /descendant-or-self::{rule@context}[{assert@test}]. This may introduce full document scans. Full document scans should be avoided at all costs.

Message

The contents of the <message> element will be shown in a card in the side bar. This message may contain zero or more <value-of> elements having an select attrbiute containing an XPath expression. These elements will be substituted with the string result of said expression. The fonto:markup-label() xpath function may be useful here.

Fixes

Content issues may be fixed using a number of operations which may be included in the schematron file. These should be in a <fixOperations> element, in the "http://www.fontoxml.com/ns/schematron-operations" namespace.

The <fixOperations> element may contain one or more <operation> elements with an attribute name. This name is the name of the operation which will be executed.

Example

XML

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:test="http://purl.oclc.org/dsdl/schematron" xmlns:ops="http://www.fontoxml.com/ns/schematron-operations" xml:lang="en">
	<sch:title>Some title</sch:title>
	<sch:ns prefix="" uri="htp://fontoxml.com/ns"/>
	<sch:pattern>
		<sch:title>Unique ids</sch:title>
		<sch:rule context="*[@id]">
			<sch:assert test="not(@id = '2')">
				<sch:message>Id attributes should be unique in a document.</sch:message>
				<ops:fixOperations>
					<ops:operation name="delete-node"/>
				</ops:fixOperations>
			</sch:assert>
		</sch:rule>
	</sch:pattern>
</sch:schema>