25. schematron

<schematron
  location = anyURI
  phase = non empty token
  evaluatePhase = boolean : false
>

Specifies which Schematron schema to use to validate the document being edited.

Note that a Schematron schema is by no mean a replacement for grammars: DTD, W3C XML Schema or RELAX NG schema. A Schematron schema is mainly useful to enforce business rules. Example: the authors in your organization must write articles conforming to the DocBook grammar but they also need to follow this business rule: first section must have a title called "Introduction" and last section must have a title called "Conclusion".

XXE built-in Schematron implementation supports both ISO Schematron or Schematron 1.5 schemas. The only supported query language binding is XSLT 1 (queryBinding="xslt").

Attributes:

location

URL of the Schematron schema.

Note that location may point to a schema other than a schematron, but where some Schematron elements have been embedded (typically RELAX NG, but not with the compact syntax).

phase

The ID of the phase to use for validation. By default, #DEFAULT if a default phase has been declared in the schematron, #ALL otherwise.

The value of this attribute may also be an XPath expression which is used to compute the ID of the phase based on the contents of the document being edited. See evaluatePhase below.

evaluatePhase

If this attribute is specified with value true, then attribute phase is understood as being an XPath expression rather than a literal phase ID. Each time a Schematron validation is to be performed, this XPath expression is evaluated in the context of the document and is expected to return the ID of the phase which is to be used for the validation.

DocBook 5 (RELAX NG) example:

<schematron location="docbook.sch" />

DocBook 4.4 (DTD) example:

<schematron location="docbook.sch"
            phase="if(/*/@status='draft','empty','#ALL')" 
            evaluatePhase="true" />

The meaning of the phase attribute is: if we are working on a draft document, no real schematron validation (phase ID = empty) should be performed. (The schematron docbook.sch actually contains an empty phase having empty as its ID, that is, <sch:phase id="empty"/>.)