Schema-level parameters (top-level param elements)

Table of Contents

Declaration
Related GitHub issue(s)
Sample usage
Commentary

Clauses 5.4.11 (param element)

The param element specifies a name-value pair providing parameters for an abstract pattern or a schema. [...] The value attribute is a fragment of a query. The value attribute is required for parameters specified for schemas. The value of a parameter for a schema may be overridden at user option. This mechanism is implementation-defined.

Parameter names shall be distinct within the scope of a pattern or schema.

Declaration

element schema {
        attribute id { xsd:ID }?,
        rich,
        attribute schemaVersion { non-empty-string }?,
        attribute schematronEdition { non-empty-string }?,
        attribute defaultPhase { xsd:IDREF }?,
        attribute queryBinding { non-empty-string }?,
        (foreign
         & (inclusion | extends)*
         & (title?, ns*, p*, param*, let*, phase*, abstract-rules*, (rule-set|pattern)+, p*, diagnostics?, properties?))
    }

Related GitHub issue(s)

Pass parameters to the validating stylesheet at validation runtime

Sample usage

Example 16. Schema-level parameters

Validating a document against this schema:

<sch:schema>
  <sch:param name='myParam' value='"bar"'/>
  <sch:pattern id='foo'>
    <sch:rule context='*'>
      <sch:assert test='false()'><sch:value-of select='$myParam'/></sch:assert>
    </sch:rule>
  </sch:pattern>
</sch:schema>

would result in SVRL containing:

<svrl:failed-assert test='false()'>bar</svrl:failed-assert>

Commentary

Note the wording "[...] may be overridden at user option", which means overriding a parameter in this way is permitted but is not a feature implementations are obliged to support.