# API for ISO Schematron Skeleton

##

Rick Jelliffe, 2010/04/14

This document provides documentation on the XSLT API available in the implementation of Schematron called `iso_schematron_skeleton.xsl`. (available in an XSLT1 and XSLT2 version). The API makes available as much information from the schema, however there may be some edge cases where it is not exhaustive.

The skeleton is an XSLT script which provides all the basic parsing and validating routines for compiling a Schematron schema into XSLT. Schematron was designed to allow many different uses, and the skeleton gives you a headstart in creating a customized implementation. You just need to write XSLT templates to override the default ones. (The program you write is sometimes called a meta-stylesheet.) It is the meta-stylesheet that is called as the XSLT script, not the skeleton. There are several pre-processing stages which the Schematron schema should be processed through first, to handle such things as include statements and abstract patterns.

Phases and error reporting for problems in the schema itself are handled by the skeleton with no interaction with a “meta-stylesheet”. Note that there is no guarantee that the context node is always the element being handled: in most cases the only information available is the information in the parameters.

For an introductory tutorial on using this API, see Bob DuCharme's Schematron 1.5: Looking Under the Hood

# Superset of API for Schematron 1.5 and 1.6

(This is an updated version of the API for the Schematron 1.5 implementation called `skeleton1-5.xsl`, which in turn comes from the new architecture contributed by Oliver Becker for Schematron 1.3.)

The current API contains only additions. Well-written meta-stylesheets that use the new API will be be able to run on the existing 1.5 and 1.6 skeletons. Similarly, it should be possible to upgrade the skeleton from 1.5 or 1.6 to the iso-schematron-skeleton only by correcting the import statement at the beginning of the meta-stylsheet. Additions or re-groupings from the 1.5 schema are shown in red. Deletions have overstrike.

Mooted addition: a parameter @action which for specifying processing instructions on assertions and reports.

## `process-prolog`

The `process-prolog` template gets called at the start of the validation session. It has no parameters. The default implementation is no action.

## `process-root`

The `process-root` template processes the root element of the schema (which is not the same thing as the root of the document / and need not be the document element /*) .

`node-list` `$contents`
`string` `$schemaVersion`
  The version of the schema, perhaps a datestamp.
`"xslt" | "xpath" | "xslt2" | ...` `$queryBinding`
  The query language binding.
`string` `$title`
  The title of this schema
`"iso" | "1.5" | "1.6" | ...` `$version`
  The version of Schematron being used.

Rich properties:

`XML SystemId` `$icon`
  The URI of an icon
`XML ID` `$id`
  The unique identifier with the schema for the `schema` element.
`SGML FPI` `$fpi`
  The Formal Public Identifier for this schema.
`IETF language` `$lang`
  The human language used in this schema, from xml:lang
`URL` `$see`
  Link to documentation on WWW or file
`"preserve" | "default"` `$space`
  The value for xml:space

To print the documentation paragraphs, use `<xsl:apply-templates mode="do-schema-p" />`

To output the results, use `<xsl:copy-of select="$contents" />`

## `process-assert`

The `process-assert` template handles asserts whose test has failed.

`XPath` `$test`
  The test
`XML IDREFS` `$diagnostics`
  A list of the idrefs diagnostic elements related to the current assertion
`XML NMTOKEN` `$flag`
  The name of a flag that becomes true because this assertion fails. The flag is true for the document if it is flagged true on any assertion. For compatability, this parameter should not be used with Schematron 1.5.

Rich properties:

`XML SystemId` `$icon`
  The URI of an icon
`XML ID` `$id`
  The unique identifier with the schema for the `assert` element.
`SGML FPI` `$fpi`
  The Formal Public Identifier for this assertion.
`IETF language` `$lang`
  The human language used in this assertion, from xml:lang
`URL` `$see`
  Link to documentation on WWW or file
`"preserve" | "default"` `$space`
  The value for xml:space

Linking properties:

`XML NMTOKEN` `$role`
  A name for the generic role of this assertion. The schema creator would have their own vocabulary.
`XPath` `$subject`
  A path relative to the current context to some interesting node considered the subject.

To print the text contents, use `<xsl:apply-templates mode="text" />`

## `process-diagnostic`

The `process-diagnostic` template handles diagnostic messages for `assert` statements that have failed and `report` statements that have succeeded. The diagnostics are evaluated in the context of the rule.

Rich properties:

`XML SystemId` `$icon`
  The URI of an icon
`XML ID` `$id`
  The unique identifier with the schema for the `assert` element.
`SGML FPI` `$fpi`
  The Formal Public Identifier for this assertion.
`IETF language` `$lang`
  The human language used in this assertion, from xml:lang
`URL` `$see`
  Link to documentation on WWW or file
`"preserve" | "default"` `$space`
  The value for xml:space

## `process-dir`

The `process-dir` template handles bi-directionality markup, which is only needed by certain human scripts such as Arabic.

`"ltr" or "rtl" or ""` `$value`
  Left-to-right or right-to-left or unspecified

## `process-emph`

The `process-emph` template handles the markup of emphasized text in paragraphs, assertions and diagnostics. It has no parameters.

## `process-message`

The `process-message` handles default outputing of text.

`string` `$pattern`
  Some text that may be some kind of pattern
`string` `$role`
  Some text that may be some kind of role

## `process-name`

The `process-name` templates handle name strings that can be used in assertions. `asssert` and `report` only provide `name` subelements rather than the more general `value-of` elements to encourage plain language and generic descriptions rather than specific diagnostics, for which purpose the `diagnostics` elements are used.

`string` `$name`
  The name of the current element, or of the node specified by a `name` element

## `process-ns`

The `process-ns` template reports on `ns` declarations, which are used to transmit on namespace information by the skeleton.

`Namespace NCName` `$prefix`
  The prefix of a namespace
`XML SystemId` `$uri`
  The (internationalized) URI Reference of a namespace

## `process-p`

The `process-p` template handles paragraphs.

`XML NMTOKEN` `$class`
  An attribute that can be used for stylesheet style
`XML ID` `$id`
  The unique identifier with the schema for the `p` element.
`XML SystemId` `$icon`
  The URI of an icon
`IETF Language` `$lang`
  The human language used in this paragraph

To print the text contents, use `<xsl:apply-templates mode="text" />`

## `process-pattern`

The `process-pattern` reports on the start of evaluation of a `pattern` element.

`string` `$name`
  The title of the current pattern
`XML NCNAMES` `$is-a`
  Empty or not provided if the pattern is not derived from an abstract pattern. Otherwise the name of the abstract pattern. A list may be used if there was a sequence of abstract patterns.

Rich properties:

`XML SystemId` `$icon`
  The URI of an icon
`XML ID` `$id`
  The unique identifier with the schema for the `pattern` element.
`SGML FPI` `$fpi`
  The Formal Public Identifier for this pattern.
`IETF language` `$lang`
  The human language used in this pattern, from xml:lang
`URL` `$see`
  A (internationalized) URI reference to some supporting or defining documentation
`"preserve" | "default"` `$space`
  The value for xml:space

To print the documentation contents, use `<xsl:apply-templates mode="do-pattern-p"/>`

## `process-report`

The `process-report` template handles `report` whose test has succeeded.

`XPath` `$test`
  The test
`XML IDREFS` `$diagnostics`
  A list of the diagnostic elements related to the current assertion
`XML NMTOKEN` `$flag`
  The name of a flag that becomes true because this assertion fails. The flag is true for the document if it is flagged true on any assertion. For compatability, this parameter should not be used with Schematron 1.5.

Rich properties:

`XML SystemId` `$icon`
  The URI of an icon
`XML ID` `$id`
  The unique identifier with the schema for the `report` element.
`SGML FPI` `$fpi`
  The Formal Public Identifier for this report.
`IETF language` `$lang`
  The human language used in this report, from xml:lang
`URL` `$see`
  Link to documentation on WWW or file
`"preserve" | "default"` `$space`
  The value for xml:space

Linking properties:

`XML NMTOKEN` `$role`
  A name for the generic role of this assertion. The schema creator would have their own vocabulary.
`XPath` `$subject`
  A path relative to the current context to some interesting node considered the subject.

To print the text contents, use `<xsl:apply-templates mode="text" />`

## `process-rule`

The `process-rule` reports that a `rule` element has fired: its `context` attribute matched some nodes. .

`XSLT expression` `$context`
  The expression that gives the context of the current

Rich properties:

`XML SystemId` `$icon`
  The URI of an icon
`XML ID` `$id`
  The unique identifier with the schema for this `rule` element.
`SGML FPI` `$fpi`
  The Formal Public Identifier for this rule.
`IETF language` `$lang`
  The human language used in this rule, from xml:lang
`URL` `$see`
  Link to documentation on WWW or file
`"preserve" | "default"` `$space`
  The value for xml:space

Linking properties:

`XML NMTOKEN` `$role`
  A name for the generic role of this assertion. The schema creator would have their own vocabulary.
`XPath` `$subject`
  A path relative to the current context to some interesting node considered the subject.

## `process-span`

The `process-span` handles span elements, which are generic elements for styling, like HTML's .

`XML NMTOKEN` `$class`
  An attribute that can be used for stylesheet style

## `process-title`

The `process-title` handles title elements, which are generic elements for styling, like HTML's .

`XML NMTOKEN` `$class`
  An attribute that can be used for stylesheet style

By default, titles are handled by invocing `process-p` with the parameter class with a value "title".

## `process-value-of`

The `process-value-of` template handles `value-of` elements, which are used in diagnostic messages to allow very specific hinting .

`XPath` `$select`
  The path of some node that will be evaluated and printed.

# Global Parameters

There are several global parameters that may be available for use. However, it is not a requirement to follow these, and implementations may not supply them with any value. So a test of string-length(variable) < 0 is appropriate in each case.

Parameter | Value | Description
allow-foreign | "true" | "false" (default) | Pass non-Schematron elements to the generated stylesheet. Pass the Schematron elements span, emph and dir: to the output SVRL.
fileNameParameter | string | A parameter passed to the Validator and potentially available as a variable in Schematron schemas as $fileNameParameter
fileDirParameter | string | A parameter passed to the Validator and potentially available as a variable in Schematron schemas as $fileDirParameter
archiveNamePaameter | string | A parameter passed to the Validator and potentially available as a variable in Schematron schemas as $archiveNameParameter
archiveDirParameter | string | A parameter passed to the Validator and potentially available as a variable in Schematron schemas as $archivePathParameter
debug | “true” | “false” (default) | Verbose error messages (Note this may be superceded by “verbose” at some stage in the future.)
generate-paths | true|false | generate the SVRL @location attribute with XPaths
diagnose | yes | no | Add the diagnostics to the assertion results
terminate | yes | no | true | false | assert | Terminate on the first failed assertion or successful report
message-newline | "true" (default) | "false" | Generate an extra newline at the end of messages
output-encoding | string | The encoding used for output, for example if the output is XML