In the last article, we grouped assertions into rules. As you know, each rule has its own context that it acts upon. So, grouping assertions into a rule provides a way to organize assertions that apply to the same elements. In this article, we'll start by explaining patterns, which takes organization to a new level.
Rules can also be related to one another. For example, although rules can have different contexts, some can perform the same types of operations on one another. Some rules may deal with the structure of a document, checking for the presence of certain elements and attributes. These rules would have different contexts, but they would be related.
Other rules may operate on different contexts in the same hierarchy. For example, one rule could operate on one element, and another rule could operate on a child of that element. Yet another rule could operate on the child of that element's child. These rules also have different contexts, but they are also very related.
Just as related assertions can be grouped into rules, related rules can be grouped into Schematron patterns. A pattern is simply a group of rules that place similar constraints on a document. The above example sets of rules could all be grouped into patterns.
Creating a basic pattern isn't very hard at all. The simplest way to create a pattern is simply to wrap a set of rules in a bare pattern tag: