Basically Schematron tests an XPath, and issues a message. The intent is that the
content of <sch:assert> be a natural language assertion.
<sch:rule context="tei:lg[@type='limerick']"> <sch:assert test="count( child::tei:l ) = 5">A limerick has 5 lines</sch:assert> </sch:rule>
Schematron tests a given XPath, and issues a message if the test fails. The content
of
<sch:assert> is going to show up as an error message, so it should be an
assertion that will make sense to your encoders.
Here, we see a <sch:rule> which says look for all of the TEI <lg>
elements that have the value of "limerick" on @type. This is where the context attribute
comes in. Its value is a bit of XPath. Note that you need to include the namespace
in
the value of context. This basically specifies which specific XML language you are
using, and provides context for the element.
The <sch:assert> element has the attribute @test, which is where you create the
actual Schematron test. Here, the test is saying that you should count all of the
children that are TEI <l> elements, and these should equal exactly 5. If there
are 6 <l> elements or only 3 or 4, Schematron will give you the warning that
occurs in the content of <sch:assert>.