More Schematron Features - Phases
(Page 4 of 5 )
Assertions can be grouped into rules, and rules can be grouped into patterns. In a similar way, patterns can be grouped into what are called phases. However, phases are different from rules and patterns in that a single pattern can belong to more than one phase. This is because a phase is declared differently from rules and patterns. Instead of containing the patterns themselves, a phase is populated with patterns using the active element, which represents a pattern active within a phase.
Phases allow for different “versions” of a schema. When the document is validated, the user may be able to select which phase to use. When a phase is chosen, then only the active patterns within that phase will be used to validate the document.
Creating a phase is easy. You simply need to use the phase element and set the id attribute in order to give the phase a unique identifier. Below, we create a phase by the name of “phase1”:
<phase id="phase1">
...
</phase>
In order to add a pattern to a phase, the active element is used. The only attribute of the active element is pattern, which is set to the identifier of the pattern you wish to add. Below, we add a pattern named “pattern1” to the phase:
<phase id="phase1">
<active pattern="pattern1"/>
</phase>
If this phase is used for validation, only pattern1 will be used to validate the document because it is the only active pattern within the phase. All other patterns are inactive.
The names “#ALL” and “#DEFAULT” cannot be used to name a phase. The former is used to indicate that all phases are active. This is the default behavior if no particular phase is specified. The latter is used to indicate that the default phase is active. You can set the default phase of a schema by setting the defaultPhase attribute of the schema element:
<schema xmlns="http://purl.oclc.org/dsdl/schematron" defaultPhase="phase1">
By default, phase1 will be used for validating a document using the schema.
Next: Diagnostics >>
More XML Articles
More By Peyton McCullough