22. schematron
Prev | Chapter 7. Configuration elements | Next

## 22. schematron

    <schematron
      location = anyURI
      namespaceAware = boolean : true
      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`".

Attributes:

location

  URL of the Schematron schema. Both ISO Schematron or Schematron 1.5 are supported.

  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).

namespaceAware

  Specify `true` for documents conforming to a DTD.

  Remember that with XXE, documents conforming to a DTD are not namespace aware. Example, if such document contains an element having `mml:math` as its name, this name is understood as being `{}mml:math` (no namespace, "`mml:math`" local part) and not as being `{http://www.w3.org/1998/Math/MathML}math` ("`http://www.w3.org/1998/Math/MathML`" namespace, "`math`" localpart).

  When a document is not namespace aware, then the schematron used to validate such document must interpret qualified names accordingly. Attribute `namespaceAware`=`true` ensures that this is the case.

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, not namespace aware) example:

    <schematron location="docbook.sch" namespaceAware="false"
                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"/>`.)

Prev | Up | Next
21. schema | Home | 22.1. Relationship between `schematron` and `documentHook`