Skip to content

Schematron Best Practices

Philip Helger edited this page Jul 9, 2024 · 1 revision

Schematron Best Practices

This page tries to collect best practices around Schematron. The recommendations will grow over time, so check back later.

Design Time

Schematron Rules Description
Try to avoid <rule> context values that start with or contain // The selection of XML elements using // is very slow and should be avoided to improve execution speed
Favour forward references over backward references in XPath To support the execution via streaming, only forward references (e.g. a/b) should be used. Backward reference (e.g. ../c/d) would require to go back in the stream which is not possible in streaming without storing the full data store.
Clearly state the engine (incl. the XSLT version if needed) your file requires. E.g. XSLT1 has no function to check for regular expressions, whereas XSLT2 can use the matches function.