Schematron Conformance Testsuite

As of 2020-08-29 there are 49 conformance tests defined.

Testcases

A pattern variable has global scope

ISO Schematron 2016: Section 5.4.5 clause 1

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:let name="foobar" value="1"/><sch:rule context="/"><sch:assert test="true()"/></sch:rule></sch:pattern><sch:pattern><sch:rule context="/"><sch:assert test="$foobar = 1"/></sch:rule></sch:pattern></sch:schema>

A rule variable can use a phase variable

ISO Schematron 2016: Section 6.5 clause 6

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:phase id="phase"><sch:let name="phase-var" value="1"/><sch:active pattern="pattern"/></sch:phase><sch:pattern id="pattern"><sch:rule context="*"><sch:let name="rule-var" value="$phase-var + 1"/><sch:assert test="$rule-var = 2"/></sch:rule></sch:pattern></sch:schema>

A rule variable can use a schema variable

ISO Schematron 2016: Section 6.5 clause 6

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:let name="global-var" value="1"/><sch:pattern><sch:rule context="*"><sch:let name="rule-var" value="$global-var + 1"/><sch:assert test="$rule-var = 2"/></sch:rule></sch:pattern></sch:schema>

A xsl:copy-of inside a sch:property is executed

ISO Schematron 2016: Annex C Clause 11 (xslt), Annex H Clause 11 (xslt2)

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*"><sch:assert test="false()" properties="copy-of"/></sch:rule></sch:pattern><sch:properties><sch:property id="copy-of"><xsl:copy-of select="."/></sch:property></sch:properties></sch:schema>

An abstract pattern is instantiated

ISO Schematron 2016: Section 6.3

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern abstract="true" id="abstract-pattern"><sch:rule context="$context"><sch:assert test="$placeholder = 0"/></sch:rule></sch:pattern><sch:pattern is-a="abstract-pattern"><sch:param name="context" value="element"/><sch:param name="placeholder" value="1"/></sch:pattern></sch:schema>

An abstract rule is instantiated

ISO Schematron 2016: Section 5.4.12 clause 5

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule abstract="true" id="abstract-rule"><sch:report test="self::element"/></sch:rule><sch:rule context="element"><sch:extends rule="abstract-rule"/></sch:rule></sch:pattern></sch:schema>

An xsl:key element can have element content

ISO Schematron 2016: Annex H, XSLT 2.0 Section 16.3.1

This test requires the processor to support the following features: xslt2.

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><xsl:key name="key" match="*"><xsl:text>key</xsl:text></xsl:key><sch:pattern><sch:rule context="/"><sch:assert test="count(key('key', 'key')) = 1"/></sch:rule></sch:pattern></sch:schema>

Context node is a comment node

ISO Schematron 2016: Annex C Clause 2 (xslt), Annex H Clause 2 (xslt2), Annex I Clause 2 (xpath2)

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<root><--  Comment!  --></root>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="comment()"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Context node is a processing instruction node

ISO Schematron 2016: Annex C Clause 2 (xslt), Annex H Clause 2 (xslt2), Annex I Clause 2 (xpath2)

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<root><?processing-instruction foobar ?></root>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="processing-instruction()"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Context node is a text node

ISO Schematron 2016: Annex C Clause 2 (xslt), Annex H Clause 2 (xslt2)

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<root>Content</root>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="text()"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Context node is an attribute node

ISO Schematron 2016: Annex C Clause 2 (xslt), Annex H Clause 2 (xslt2), Annex I Clause 2 (xpath2)

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element attribute="value"/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="@attribute"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Context node is an element node

ISO Schematron 2016: Annex C Clause 2 (xslt), Annex H Clause 2 (xslt2), Annex I Clause 2 (xpath2)

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="element"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Context node is the root node

ISO Schematron 2016: Annex C clause 2 (xslt), Annex H clause 2 (xslt2)

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<root/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Diagnostic references are copied to SVRL output

This test requires the processor to support the following features: svrl.

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:report test="true()" diagnostics="d1 d2"/></sch:rule></sch:pattern><sch:diagnostics><sch:diagnostic id="d1">
          Context: <sch:value-of select="name()"/></sch:diagnostic><sch:diagnostic id="d2">
          Context: <sch:value-of select="name()"/></sch:diagnostic></sch:diagnostics></sch:schema>

Extends is recursive

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element/>

Secondary documents

include.sch

<rule><extends href="true.sch"/></rule>

true.sch

<rule context="/"><report test="true()"/></rule>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:extends href="include.sch"/></sch:rule></sch:pattern></sch:schema>

Extends performs base URI fixup

XML Inclusions (XInclude) Version 1.1, Section 4.7.5.

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Secondary documents

subdir/include.sch

<rule context="/"><assert test="local-name(document('include.sch')/*[1]) = 'rule'"/></rule>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:extends href="subdir/include.sch"/></sch:rule></sch:pattern></sch:schema>

Include is recursive

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element/>

Secondary documents

pattern.sch

<pattern><include href="rule.sch"/></pattern>

rule.sch

<rule context="/"><report test="true()"/></rule>

Schematron for any query binding

<sch:schema><sch:include href="pattern.sch"/><sch:pattern/></sch:schema>

Include performs base URI fixup

XML Inclusions (XInclude) Version 1.1, Section 4.7.5.

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element/>

Secondary documents

subdir/include.sch

<rule context="/"><report test="local-name(document('include.sch')/*[1]) = 'rule'"/></rule>

Schematron for any query binding

<sch:schema><sch:pattern><sch:include href="subdir/include.sch"/></sch:pattern></sch:schema>

It is an error for a variable to be multiply defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:let name="foo" value="'bar'"/><sch:pattern><sch:let name="foo" value="'bar'"/><sch:rule context="/"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

It is an error for a variable to be multiply defined in the current pattern

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:let name="foo" value="'bar'"/><sch:let name="foo" value="'bar'"/><sch:rule context="/"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

It is an error for a variable to be multiply defined in the current phase

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:phase id="phase"><sch:let name="foo" value="'bar'"/><sch:let name="foo" value="'bar'"/><sch:active pattern="pattern"/></sch:phase><sch:pattern id="pattern"><sch:rule context="/"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

It is an error for a variable to be multiply defined in the current rule

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:let name="foo" value="'bar'"/><sch:let name="foo" value="'bar'"/><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

It is an error for a variable to be multiply defined in the current schema

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:let name="foo" value="'bar'"/><sch:let name="foo" value="'bar'"/><sch:pattern><sch:rule context="/"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

It is an error to define a pattern variable with the same name as a global variable

ISO Schematron 2016: Section 5.4.5 clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:let name="foobar" value="1"/><sch:pattern><sch:let name="foobar" value="1"/><sch:rule context="/"><sch:assert test="true()"/></sch:rule></sch:pattern><sch:pattern><sch:rule context="/"><sch:assert test="$foobar = 1"/></sch:rule></sch:pattern></sch:schema>

It is an error to extend an abstract rule that is defined in a different pattern

ISO Schematron 2016: Section 5.4.12 clause 5

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule abstract="true" id="abstract-rule"><sch:report test="self::element"/></sch:rule></sch:pattern><sch:pattern><sch:rule context="element"><sch:extends rule="abstract-rule"/></sch:rule></sch:pattern></sch:schema>

It is an error to reference a variable in a rule context expression that has not been defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*[local-name() = $localname]"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

It is an error to reference a variable in an assert test expression that has not been defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*"><sch:assert test="$variable = 1"/></sch:rule></sch:pattern></sch:schema>

It is an error to reference a variable in an report test expression that has not been defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*"><sch:report test="$variable = 1"/></sch:rule></sch:pattern></sch:schema>

It is an error to reference a variable in an rule variable that has not been defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*"><let name="ruleVariable" value="$variable"/><sch:assert test="$ruleVariable"/></sch:rule></sch:pattern></sch:schema>

It is an error to reference a variable in the @path expression of a sch:name element that has not been defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*"><sch:assert test="false()"><sch:name path="$variable"/></sch:assert></sch:rule></sch:pattern></sch:schema>

It is an error to reference a variable in the @select expression of a sch:value-of element that has not been defined globally

ISO Schematron 2016: Section 5.4.5 Clause 3

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="*"><sch:assert test="false()"><sch:value-of select="$variable"/></sch:assert></sch:rule></sch:pattern></sch:schema>

It is an error to reference an undefined variable in the @documents expression of a sch:pattern element

ISO Schematron 2016: Section 5.4.5 Clause 3

This test requires the processor to support the following features: iso2016.

Running Schematron validation with this input should cause an error.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern documents="$variable"><sch:rule context="*"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

Language tag of diagnostic is preserved in SVRL output

This test requires the processor to support the following features: svrl.

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:report test="true()" diagnostics="d1"/></sch:rule></sch:pattern><sch:diagnostics><sch:diagnostic id="d1" xml:lang="de">
          Context: <sch:value-of select="name()"/></sch:diagnostic></sch:diagnostics></sch:schema>

Let uses the element content as value

ISO Schematron 2016: Section 5.4.5 clause 2

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for query binding 'xslt'

<sch:schema queryBinding="xslt"><sch:ns prefix="html" uri="http://www.w3.org/1999/xhtml"/><sch:let name="foobar"><html:p>This is a paragraph</html:p></sch:let><sch:pattern><sch:rule context="/"><sch:assert test="contains($foobar, 'paragraph')"/></sch:rule></sch:pattern></sch:schema>

Schematron for any other query binding

<sch:schema><sch:ns prefix="html" uri="http://www.w3.org/1999/xhtml"/><sch:let name="foobar"><html:p>This is a paragraph</html:p></sch:let><sch:pattern><sch:rule context="/"><sch:assert test="count($foobar/html:p) = 1"/></sch:rule></sch:pattern></sch:schema>

Lexical order of rules is significant

ISO Schematron 2016: Section 6.5 Clause 5

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="element"><sch:assert test="true()"/></sch:rule><sch:rule context="*"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Pattern in a subordinate document

ISO Schematron 2016: Section 5.4.9 clause 2

This test requires the processor to support the following features: iso2016.

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element secondary="document-02.xml"/>

Secondary documents

document-02.xml

<root/>

Schematron for any query binding

<sch:schema><sch:pattern documents="/element/@secondary"><sch:rule context="/"><sch:report test="root"/></sch:rule></sch:pattern></sch:schema>

Pattern-variable is scoped to the pattern

ISO Schematron 2016: Section 3.26

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><sch:let name="foo" value="0"/><sch:pattern><sch:let name="foo" value="1"/><sch:rule context="*"><sch:assert test="$foo = 1"/></sch:rule></sch:pattern><sch:pattern><sch:rule context="*"><sch:assert test="$foo = 0"/></sch:rule></sch:pattern></sch:schema>

Property references are copied to SVRL output

This test requires the processor to support the following features: svrl.

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:report test="true()" properties="p1 p2"/></sch:rule></sch:pattern><sch:properties><sch:property id="p1">
          Context: <sch:value-of select="name()"/></sch:property><sch:property id="p2">
          Context: <sch:value-of select="name()"/></sch:property></sch:properties></sch:schema>

Rule context expression uses a pattern variable

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:let name="local-name" value="'document'"/><sch:rule context="*[local-name() = $local-name]"><sch:assert test="true()"/></sch:rule><sch:rule context="*"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Rule context expression uses a phase variable

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><sch:phase id="phase"><sch:let name="local-name" value="'document'"/><sch:active pattern="pattern"/></sch:phase><sch:pattern><sch:rule context="*[local-name() = $local-name]"><sch:assert test="true()"/></sch:rule><sch:rule context="*"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Rule context expression uses a schema variable

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><sch:let name="local-name" value="'document'"/><sch:pattern><sch:rule context="*[local-name() = $local-name]"><sch:assert test="true()"/></sch:rule><sch:rule context="*"><sch:assert test="false()"/></sch:rule></sch:pattern></sch:schema>

Rule-variable is scoped to the rule

ISO Schematron 2016: Section 3.26

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><sch:let name="foo" value="0"/><sch:phase id="phase"><sch:let name="foo" value="1"/><sch:active pattern="pattern"/></sch:phase><sch:pattern id="pattern"><sch:rule context="/"><sch:assert test="$foo = 1"/></sch:rule></sch:pattern></sch:schema>

Rule-variable is scoped to the rule

ISO Schematron 2016: Section 3.26

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<document/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/"><sch:let name="foo" value="1"/><sch:assert test="$foo = 1"/></sch:rule><sch:rule context="*"><sch:let name="foo" value="0"/><sch:assert test="$foo = 0"/></sch:rule></sch:pattern></sch:schema>

The sch:name element expands into the name of the context node if no @path is present

ISO Schematron 2016: Section 5.4.6, Annex C clause 4 (xslt), Annex H clause 4 (xslt2), Annex I clause 4 (xpath2)

This test requires the processor to support the following features: svrl.

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/element"><sch:report test="true()"><sch:name/></sch:report></sch:rule></sch:pattern></sch:schema>

The sch:name element expands into the value of evaluating the expression in @path

ISO Schematron 2016: Section 5.4.6, Annex C clause 4 (xslt), Annex H clause 4 (xslt2), Annex I clause 4 (xpath2)

This test requires the processor to support the following features: svrl.

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element attribute="value"/>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/element"><sch:report test="true()"><sch:name path="@attribute"/></sch:report></sch:rule></sch:pattern></sch:schema>

The sch:value-of element expands into the value of evaluating the expression in @select

ISO Schematron 2016: Section 5.4.14, Annex C clause 5 (xslt), Annex H clause 5 (xslt2), Annex I clause 5 (xpath2)

This test requires the processor to support the following features: svrl.

Running Schematron validation with this input should report an invalid document.

In addition, the following XPath expressions are expected to return the effective boolean value of true() when evaluated with the output of the Schematron validation process as context node:

Primary document

document.xml

<element>Text content</element>

Schematron for any query binding

<sch:schema><sch:pattern><sch:rule context="/element"><sch:report test="true()"><sch:value-of select="."/></sch:report></sch:rule></sch:pattern></sch:schema>

The subordinate document expression contains a variable

This test requires the processor to support the following features: iso2016.

Running Schematron validation with this input should report an invalid document.

Primary document

document.xml

<element secondary="document-02"/>

Secondary documents

document-02.xml

<root/>

Schematron for any query binding

<sch:schema><sch:let name="extension" value="'.xml'"/><sch:pattern documents="concat(/element/@secondary, $extension)"><sch:rule context="/"><sch:report test="root"/></sch:rule></sch:pattern></sch:schema>

When a phase named '#DEFAULT' is given, the processor uses the phase given in @defaultPhase

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema defaultPhase="phase"><sch:phase id="phase"><sch:active pattern="pass"/></sch:phase><sch:pattern id="fail"><sch:rule context="*"><sch:assert test="false()"/></sch:rule></sch:pattern><sch:pattern id="pass"><sch:rule context="*"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>

When no phase is given, the processor uses the phase given in @defaultPhase

ISO Schematron 2016: Section 5.4.13 clause 3

Running Schematron validation with this input should report a valid document.

Primary document

document.xml

<element/>

Schematron for any query binding

<sch:schema defaultPhase="phase"><sch:phase id="phase"><sch:active pattern="pass"/></sch:phase><sch:pattern id="fail"><sch:rule context="*"><sch:assert test="false()"/></sch:rule></sch:pattern><sch:pattern id="pass"><sch:rule context="*"><sch:assert test="true()"/></sch:rule></sch:pattern></sch:schema>