Table of Contents
Element context(s)
phase
This attribute is optional and activates the phase when its expression matches.
Clause 5.4.13 (
phase
element)The string
#ANY
denotes that the active phase is selected using the method given in [Clause 5.5.22] and if no active phase is selected, then all patterns are active.
Clause 5.5.22 (
when
attribute)The
when
attribute is an expression evaluated to a Boolean in the context of the instance document root. If the expression evaluates totrue()
, then its parent phase becomes active. The first such phase declared in schema document order shall be the active phase.This behaviour shall not apply to subordinate documents, that is those selected by the
documents
attribute [...].
phase =
element phase {
attribute id { xsd:ID },
attribute from { text }?,
attribute when { pathValue }?,
rich,
(foreign & inclusion* & (p*, let*, active*))
}
Example 11. from
attribute
Given this instance document:
<foo> <blort wibble='1'/> <bar><blort wibble='2'/><blort wibble='3'/></bar> </foo>
and this schema:
<sch:schema> <sch:phase id='foo' when='/foo'> <sch:active pattern='wibble-1'/> </sch:phase> <sch:phase id='wibble' when='//@wibble'> <sch:active pattern='wibble-2'/> </sch:phase> <sch:phase id='bar' when='/foo/bar'> <sch:active pattern='wibble-3'/> </sch:phase> <sch:pattern id='wibble-1'> <sch:rule context='//blort[@wibble]'> <sch:report test='@wibble'><sch:value-of select='@wibble'/></sch:report> </sch:rule> </sch:pattern> <sch:pattern id='wibble-2'> <sch:rule context='//blort[@wibble]'> <sch:report test='@wibble'><sch:value-of select='@wibble/..'/></sch:report> </sch:rule> </sch:pattern> <sch:pattern id='wibble-3'> <sch:rule context='//blort[@wibble]'> <sch:assert test='normalize-space(@wibble)'>value must not be empty</sch:assert> </sch:rule> </sch:pattern> </sch:schema>
all instances of the when
attribute match when evaluated against the document instance, but only the first matching phase in document order (wibble-1
) is selected:
<svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl" phase="foo"> <svrl:active-pattern id="wibble-1"/> <svrl:fired-rule context="//blort[@wibble]"/> <successful-report xmlns="http://purl.oclc.org/dsdl/svrl" location="/Q{}foo[1]/Q{}blort[1]" test="@wibble"> <svrl:text>1</svrl:text> </successful-report> <successful-report xmlns="http://purl.oclc.org/dsdl/svrl" location="/Q{}foo[1]/Q{}bar[1]/Q{}blort[1]" test="@wibble"> <svrl:text>2</svrl:text> </successful-report> <successful-report xmlns="http://purl.oclc.org/dsdl/svrl" location="/Q{}foo[1]/Q{}bar[1]/Q{}blort[2]" test="@wibble"> <svrl:text>3</svrl:text> </successful-report> </svrl:schematron-output>
![]() | Note |
---|---|
This result is obtained only if the implementation is invoked using If no phase is selected with this schema, the behaviour matches that of specifying |
The introduction of this attribute entails the new string #ANY
to specify that when
should be used to determine the active phase.
Like #ALL
and #DEFAULT
, #ANY
is not to be used as a phase name in a schema, but instead to invoke or configure validation, for example when passed as a parameter to an implementation at the command line.