Summary

Schema composition is about arranging schemas, patterns, rules, and assertions to support different validation tasks and for the ease of maintenance by allowing reuse of assertions, rules, and patterns.

Schematron provides four ways to compose a schema.

An abstract rule is a named set of assertions and represented by a sch:rule element without a context expression. It is scoped to the containing pattern. All rules of the same pattern can use a set of assertions by referencing the name of the abstract rule in the rule attribute of a sch:extends element.

A phase is a named set of patterns defined by a top-level sch:phase element. Phases allow one schema document to cover multiple validation scenarios or needs.

Schematron offers two mechanisms to use external definitions. The sch:include element can be used anywhere and has a href attribute that points to an external resource. The content of the resource is inserted in place of the sch:include element.

The second mechanism is build on top of the sch:extends element. Instead of a rule attribute naming an abstract rule, it may use a href attribute pointing to an external resource. If the external resource is the same element as the sch:extends element’s parent, then the child nodes of the referenced element are inserted in place of the sch:extends element. The use of sch:extends however is still restricted to the sch:rule element.