Table of Contents
Element context(s)
library
schema
Clause 5.4.16 (
rules
element)The rules element is a container for abstract rules, allowing their use across patterns. This element may be used as a top-level element in a schema and can also be used in a library.
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?))
}
element library {
attribute id { xsd:ID }?,
rich,
(foreign
& (inclusion | extends)*
& (title?, p*, param*, let*, abstract-rules*, (rule-set|pattern)*, p*, diagnostics?, properties?))
}
abstract-rules =
element rules {
attribute id { xsd:ID }?,
rich,
title?,
p*,
abstract-rule+
}
Example 14. rules
element
Given this schema:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"> <sch:rules> <sch:rule abstract="true" id="abstract-rule"> <sch:report test="self::element"/> </sch:rule> <sch:rule abstract="true" id="abstract-rule-2"> <sch:report test="name()"/> </sch:rule> </sch:rules> <sch:pattern> <sch:rule context="element"> <sch:extends rule="abstract-rule"/> </sch:rule> <sch:rule context="*"> <sch:extends rule="abstract-rule-2"/> </sch:rule> </sch:pattern> </sch:schema>
the two abstract rule
elements contained in rules
will be instantiated as usual, resulting in this expanded schema:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"> <sch:pattern> <sch:rule context="element"> <sch:report test="self::element"/> </sch:rule> <sch:rule context="*"> <sch:report test="name()"/> </sch:rule> </sch:pattern> </sch:schema>
The behaviour of abstract rules and how they are processed remains unchanged here. What is new is the container for abstract rules, which would previously have to have been stored separately and instantiated using extends/@href
.
More background on this can be found in this blog post by David Maus.